Use sets instead of dictionaries in merge_nodes