class Solution: def __init__(self): self.li = [] def midSearch(self,node): if(node != None): self.midSearch(node.left) self.li.append(node.val) self.midSearch(node.right) def rangeSumBST(self, root, L, R): self.midSearch(root) count = 0 tag = False for l in self.li: if l == L: tag = True if tag: count += l if l == R: tag = False return count