speed up the remove_disconnected_node() method