How to avoid same circular pattern getting detect multiple times

Dear community,

I am new to Cypher and Neo4j. I am trying to detect paths that start and end at the same node. But I have observed that the same pattern is getting detected multiple times. Below is my cypher query

PROFILE MATCH path=(t1:person)-[:Knows*4]->(t2:person)
WHERE t1.name=t2.name //(name is unique in my case)
RETURN path

The problem with this query if A-->B-->C-->D-->A is a pattern, it also returns
B-->C-->D-->A-->B,
C-->D-->A-->B-->C,
D-->A-->B-->C-->D.

My graph is huge and since the pattern is getting repeated I am facing a memory out error. Please let me know how do I avoid this repetition.

Thank you

Hi @nichopriyatham97

What you're describing here is expected behaviour... let me explain why...

Because you specific anchor point has been specified for your query (e.g. Person's name is Bob), if you've got something like this: (a)->(b)->(c)->(d)--> back to (a), the query will do the chain around a, then do the chain around b, etc. to d, because each of those are a valid start point.

Do you have any anchors or points that you could use to pin the query?