@Procedure @PerformsWrites @Description("apoc.refactor.mergeNodes([node1,node2]) merge nodes onto first in list") public Stream<NodeResult> mergeNodes(@Name("nodes") List<Node> nodes){
  if (nodes.isEmpty())   return Stream.empty();
  Iterator<Node> it=nodes.iterator();
  Node first=it.next();
  while (it.hasNext()) {
    Node other=it.next();
    mergeNodes(other,first,true);
  }
  return Stream.of(new NodeResult(first));
}

@ Procedure @ PerformsWrites @ Description ( "apoc.refactor.mergeNodes([node1,node2]) merge nodes onto first in list" ) public Stream < NodeResult > mergeNodes ( @ Name ( "nodes" ) List < Node > nodes ) { if ( nodes . isEmpty ( ) ) return Stream . empty ( ) ; Iterator < Node > it = nodes . iterator ( ) ; Node first = it . next ( ) ; while ( it . hasNext ( ) ) { Node other = it . next ( ) ; mergeNodes ( other , first , true ) ; } return Stream . of ( new NodeResult ( first ) ) ; }
merges the nodes onto the first node . the other nodes are deleted and their relationships moved onto that first node .
