removeDeadEndSubnetwork. fix copied from cgarreau pull request