99% faster and 96% less code using simple recursion
\n\n\nclass Solution:\n    def searchBST(self, root: Optional[TreeNode], val: int) -> Optional[TreeNode]:\n        if root and val == root.val:\n            ret
![image](https://assets.leetcode.com/users/images/d6d4e7ec-e96c-4e21-b36d-0deceab8b19d_1649932752.0958385.png)\n\n```\nclass Solution:\n    def searchBST(self, root: Optional[TreeNode], val: int) -> Optional[TreeNode]:\n        if root and val == root.val:\n            return root\n        if root and val > root.val:\n            return self.searchBST(root.right, val)\n        elif root and val < root.val:\n            return self.searchBST(root.left, val)\n        else:\n            return None\n```\n
['Recursion', 'Binary Tree', 'Python']