Swift
\n\nclass Solution {\n    func rangeSumBST(_ root: TreeNode?, _ L: Int, _ R: Int) -> Int {\n        var sum = 0\n        guard let node = root else { return sum
\n```\nclass Solution {\n    func rangeSumBST(_ root: TreeNode?, _ L: Int, _ R: Int) -> Int {\n        var sum = 0\n        guard let node = root else { return sum }\n        if L <= node.val &&  node.val <= R {\n            sum += node.val\n        }\n        if L < node.val {\n            sum = sum + rangeSumBST(node.left, L, R)\n        }\n        if node.val < R {\n            sum = sum + rangeSumBST(node.right, L, R)\n        }\n\n        return sum\n        }\n}\n```
[]