lookup_tree_path_recursive: Fix use-after-free.