I am ignoring the level and number deliberately, this way the instance travels down the tree to reach a final node. There should not be 'leakage' from one group to another, however I consider the condition LEFT.group_id = RIGHT.group_id won't harm the results nor the performance. Thanks for notice that.

	sort0 := SORT(join0, group_id, id, level, number, node_id, new_node_id);
	dedup0:= DEDUP(sort0, LEFT.group_id = RIGHT.group_id AND LEFT.id = RIGHT.id AND LEFT.new_node_id != RIGHT.node_id, KEEP 1, LEFT);
	dedup1:= DEDUP(dedup0, LEFT.group_id = RIGHT.group_id AND LEFT.id = RIGHT.id AND LEFT.new_node_id = RIGHT.node_id, KEEP 1, RIGHT);