neo4j: Replace multiple nodes with same property by one node
<p>Let's say I have a property "name" of nodes in neo4j. Now I want to enforce that there is maximally one node for a given name by identifying all nodes with the same name. More precisely: If there are three nodes where name is "dog", I want them to be replaced by just one node with name "dog", which:</p>

<ol>
<li>Gathers all properties from all the original three nodes.</li>
<li>Has all arcs that were attached to the original three nodes.</li>
</ol>

<p>The background for this is the following: In my graph, there are often several nodes of the same name which should considered as "equal" (although some have richer property information than others). Putting <code>a.name = b.name</code> in a WHERE clause is extremely slow.</p>

<p>EDIT: I forgot to mention that my Neo4j is of version 2.3.7 currently (I cannot update it).</p>

<p>SECOND EDIT: There is a known list of labels for the nodes and for the possible arcs. The type of the nodes is known. </p>

<p>THIRD EDIT: I want to call above "node collapse" procedure from Java, so a mixture of Cypher queries and procedural code would also be a useful solution.</p>