Jave easy to understand 2ms solution (tree pruning)
\nclass Solution {\n    int sum = 0;\n    public int rangeSumBST(TreeNode root, int L, int R) {\n        helper(root, L, R);\n        return sum;\n    }\n    \n
```\nclass Solution {\n    int sum = 0;\n    public int rangeSumBST(TreeNode root, int L, int R) {\n        helper(root, L, R);\n        return sum;\n    }\n    \n    public void helper(TreeNode root, int L, int R){\n        if(root == null){\n            return;\n        }\n        if(root.val <= R && root.val >= L){\n            sum += root.val;\n            helper(root.left, L, R);\n            helper(root.right, L, R);\n        }else if(root.val < L){\n            helper(root.right, L, R); //no need to go left since the left branch must be smaller than L\n        }else{ //root great than R\n            helper(root.left, L, R); //no need to go right since the right branch must be larger than R\n        }\n    }\n}\n```
[]