changed remove_common_nodes to a class method