python recursion easy to follow
```\n\nclass Solution(object):\n    def pathSum(self, root, sum):\n\n        if not root:\n            return 0\n        \n        self.ans = 0\n\n        def s
```\n\nclass Solution(object):\n    def pathSum(self, root, sum):\n\n        if not root:\n            return 0\n        \n        self.ans = 0\n\n        def search(root, memo):\n            \n            self.ans += memo.count(sum)\n            \n            if root.left:\n                search(root.left, [x+root.left.val for x in memo] + [root.left.val])\n            \n            if root.right:\n                search(root.right, [x+root.right.val for x in memo] + [root.right.val])\n                \n        search(root, [root.val])\n        return self.ans\n
['Recursion', 'Python']