More elgant way to delete the tree without worrying about back edges