[Python] 2 Elegant Solutions. Recursive and Iterative
\nclass Solution:\n    def rangeSumBST(self, root: TreeNode, L: int, R: int) -> int:\n        ## RC ##\n        ## APPROACH : RECURSION ##\n\t\t## TIME COMPLEXI
```\nclass Solution:\n    def rangeSumBST(self, root: TreeNode, L: int, R: int) -> int:\n        ## RC ##\n        ## APPROACH : RECURSION ##\n\t\t## TIME COMPLEXITY : O(N) ##\n\t\t## SPACE COMPLEXITY : O(H) ##\n        \n        def dfs(node):\n            if not node: return 0\n            if node.val < L: return dfs(node.right)\n            elif node.val > R: return dfs(node.left)\n            else: return dfs(node.left) + dfs(node.right) + node.val\n        return dfs(root)\n        \n        ## APPROACH : ITERATIVE ##\n\t\t## TIME COMPLEXITY : O(N) ##\n\t\t## SPACE COMPLEXITY : O(H) ##\n        stack = [root]\n        ans = 0\n        while(stack):\n            node = stack.pop()\n            if node:\n                if L <= node.val <= R: ans += node.val\n                if L < node.val: stack.append(node.left)\n                if R > node.val: stack.append(node.right)\n        return ans\n\n```
['Python', 'Python3']