Finding all connected nodes in a cyclic graph

I have a graph with lot of cycles in it. I want to find all nodes connected to a specific node by any length of path.
I've tried this
match (a{firstName:"XYZ"})-[ * ]-(b) return distinct b
but i think this got stuck in a cycle.
So, is their any way to do this?
Also, i was curious to know that can we find path with longest length and having distinct nodes in a cyclic graph?

I started also a post

I still searching for a find all cycle paths for a list of start nodes. The expand.cycle returns me only one path per start node.

With a subgrah, I would need a start node list and an endnode list, which is handled one on one.

First start node accepts one first endnode, not all in list