You can either BFS or DFS through the tree to find the solution. The only thing to think about is whether to recurse to the left node or the right node or both. If the node value is less than the lower bound, we know we must increase the node value, so only check the right node. If the value is greater than the upper bound, we know to only check the left node too. If its within bounds, we can add the current node, the left node, and the right node.

class Solution:
    def rangeSumBST(self, root: Optional[TreeNode], low: int, high: int) -> int:
        def recurse(node):
            if not node:
                return 0
            if low <= node.val <= high:
                return node.val + recurse(node.left) + recurse(node.right)
            if node.val < low:
                return recurse(node.right)
            if node.val > high:
                return recurse(node.left)
        
        return recurse(root)