Merge Nodes based on condition on relationship property

I started using neo4j recently.I have a scenario like

Match (a:parent)-[r:father_of]->(b:daughter)-[r1:friend_of{talks_to:5 times}]->(c:daughter)-[r2:daughter_of]->(d:parent)

Now I want to marge all these nodes to one if talks_to property of r1 relationship is more that 2 times.Or create one master node to all these, like all these belong to that family if it meets given condition.How this can be done

Have you checked out the APOC merge nodes procedure? 15.3. Merge Nodes - Chapter 15. Graph Refactoring It might be what you're looking for.

Yeah I already used that but now I want to merge parent nodes based on child node properties

I guess you are trying to merge nodes based on the Relationship property of [friend_of]

Match (a:parent)-[r:father_of]->(b:daughter)-[r1:friend_of]->(c:daughter)-[r2:daughter_of]->(d:parent)
Where toInteger(split(r1.talks_to,' ')[0]) >'2'

Yes Exactly this is what I am trying...but how to merge a,d based on that

Could you please give me small sample data set

(a:parent)-[r:father_of]->(b:daughter)-[r1:friend_of{talks_to:5 times}]->(c:daughter)-[r2:daughter_of]->(d:parent)

(a:parent)-[rr:father_of]->(e:daughter)-[rr1:friend_of{talks_to:4 times}]->(f:daughter)-[rr2:daughter_of]->(g:parent)

(g:parent)-[rrr:father_of]->(h:daughter)-[rrr1:friend_of{talks_to:1 times}]->(i:daughter)-[rr2:daughter_of]->(n:parent)

See above is my data set.Now I want to merge a,d,g nodes because their talks_to is more than 2 and n should be seperate node because g -> n talks_to is less than 2