Merge nodes when they appear more than once