# Neo4j query return node parameters in recursve loop

**URL:** <https://community.neo4j.com/t/neo4j-query-return-node-parameters-in-recursve-loop/9925>\
**Category:** Cypher\
**Tags:** cypher\
**Created:** [September 6, 2019, 8:18am UTC](https://community.neo4j.com/t/neo4j-query-return-node-parameters-in-recursve-loop/9925 "2019-09-06T08:18:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jobsforrupesh](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/jobsforrupesh/32/6284_2.png) [@jobsforrupesh](https://community.neo4j.com/u/jobsforrupesh)\
**Post date:** [September 6, 2019, 8:18am UTC](https://community.neo4j.com/t/neo4j-query-return-node-parameters-in-recursve-loop/9925/1 "2019-09-06T08:18:18Z")

</div>

I have a dynamic hierarchy of nodes & relations and want to extract max of a Node (p) associated in that hirerchy . Snippet of hierarchies is as under  
EG:- **p1\<-p2\<-p4\<-p5**  
**p1\<-p2\<-p4\<-p6**  
**p1\<-p3\<-p7\<-p8**  
**p1\<-p3\<-p7\<-p9**

I have a node c..n having relationship with each of pn nodes , I need to get maximum of property of the c..n node in each pth mentioned above.  
I am using -[:has\_relation\*]- to traverse the tree , but moment i specify p1.property1=67 and pn.property=100 , i get a single row.  
I need all rows corresponding to the path and maximum of property associated with each subnode.

each Subnode:-  
**(pn)-[:has\_other\_relation]-\>(c\_node\_n)**

Is it possible to get this in Neo4j ?  
Have thought of using _FOREACH_, but its used for merging/creating new relation/property not returning anything.

---

<div class="post-metadata">

**Author:** ![michael.hunger](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/michael.hunger/32/27377_2.png) [@michael.hunger](https://community.neo4j.com/u/michael.hunger)\
**Post date:** [September 6, 2019, 11:07am UTC](https://community.neo4j.com/t/neo4j-query-return-node-parameters-in-recursve-loop/9925/2 "2019-09-06T11:07:31Z")

</div>

Usually you can use a path expression:

like this:

```auto
MATCH path (r:Node {id:root})-[:HAS_CHILD*]->(c) WHERE not (c)-[:HAS_CHILD]->()
RETURN path

```

or the other way round if you want to start at the child
