Simple | Stack | Log(n) | Readable 
Code: Approach 1: Using Stack.Complexity
Time complexity: O(logn)

Space complexity: O(logn)
Approach 2: BFS.
# Code: Approach 1: Using Stack.
```java []
class FindElements {
    TreeNode root;
    public FindElements(TreeNode root) {
        this.root = root;
    }
    
    public boolean find(int target) {
        Stack<Boolean> stack = new Stack<>();
        for(; target != 0; target = (--target) >> 1) {
            stack.push((target & 1) == 1);
        }
        
        TreeNode curr = root;

        while(curr != null && !stack.isEmpty()) {
            boolean moveLeft = stack.pop();
            curr = moveLeft ? curr.left : curr.right;
        }
        
        return curr != null;
    }
}
```

# Complexity
- Time complexity: O(logn)
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity: O(logn)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Approach 2: BFS.
```java []
class FindElements {
    Set<Integer> set;
    public FindElements(TreeNode root) {
        set = new HashSet<>();
        recover(root);
    }

    private void recover(TreeNode root) {
        Queue<TreeNode> q = new LinkedList<>();
        root.val = 0;
        q.offer(root);

        while(!q.isEmpty()) {
            TreeNode curr = q.poll();
            set.add(curr.val);
            if(curr.left != null) {
                curr.left.val = curr.val * 2 + 1;
                q.offer(curr.left);
            }
            if(curr.right != null) {
                curr.right.val = curr.val * 2 + 2;
                q.offer(curr.right);
            }
        }
    }

    public boolean find(int target) {
        return set.contains(target);
    }
}
```

['Stack', 'Tree', 'Breadth-First Search', 'Monotonic Stack', 'Binary Tree', 'Java']