Get all nodes by relation (deep)

Hello. I have a db where each node is a Person. Persons are connected to each other by RESPONSIBLE_OF tag. Let's say A is responsible of B and C. But B is also responsible of D. I need a query that will return me the people working under A who are B, C, D (D is not directly under A but he/she is under B who is under A).
It might look like a simple query but I'm new to graph db and I really couldn't find it.

MATCH p = (a {userId: 1})-[:RESPONSIBLE_OF]->(b) RETURN b

I found this query that returns me B and C but as I stated I need D as well. Of course there is no depth limit in this search. Say if there is person E working under D as well then I want query to return B,C,D and E.

Hello @raepheles and welcome to the Neo4j community :slight_smile:

MATCH p = (a {userId: 1})-[:RESPONSIBLE_OF*]->(b) RETURN b

Regards,
Cobra

@Cobra Thank you :slight_smile:

1 Like