Different approach than sets | O(1) Space optimized| O(log(k) Time complexity for each query
IntuitionFew observations that can be made here:
All the odd numbers will be on the left child to a parent node and all the even numbers will be on right child
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
Few observations that can be made here:
1. All the odd numbers will be on the left child to a parent node and all the even numbers will be on right child to a parent.
2. To calculate child, we are given this formula: n1 = 2x + 1 and n2 =  2x + 2, then, to calculate a parent, formula would be (n1 - 1)/2 and (n2-2)/2.
3. All the odd child values are formed from the formula: 2x + 1 and even from 2x+2.
4. If we know the current node is left or right child of parent node, then we can form a path, because we can traverse from the number at the bottom to top, by knowing whether it is the right child or left child, then add it to path, and then calculate its parent, then so on until top node.
5. Once, at the top, we can traverse the path in reverse, and directly check if node exists, if exists, value must be present and return true, else return False.

# Code
```python3 []
# Definition for a binary tree node.
from typing import Optional


class TreeNode:
    def __init__(self, val=0, left=None, right=None):
        self.val = val
        self.left = left
        self.right = right


class FindElements:

    def __init__(self, root: Optional[TreeNode]):
        self.head = root

    def find(self, target: int) -> bool:
        root = self.head
        path = []
        while target:
            # check if odd
            if target & 1:
                path.append(0)
                target = (target - 1) // 2
            else:
                path.append(1)
                target = (target - 2) // 2
        # traverse path in reverse, as it is formed from the bottom
        # and now we are traversing from the top
        for dir in range(len(path) -1, -1, -1):
            if path[dir] == 0 and root.left:
                root = root.left
            elif path[dir] == 1 and root.right:
                root = root.right
            else:
                return False
        return True

```
['Design', 'Binary Tree', 'Python3']