from utils.treeNode import TreeNode

class Solution:
    def get_paths_sum(self, node, target):
        result = []
        if not node:
            return result
        
        self.get_paths_helper([], target, node, result)

        return result
    
    def get_paths_helper(self, path, target, node, result):
        if not node:
            return
        
        target -= node.value
        path.append(node.value)

        if target == 0 and not node.left and not node.right:
            result.append(path[:]) # import to add a new copy of path, because path will change
        
        self.get_paths_helper(path, target, node.left, result)
        self.get_paths_helper(path, target, node.right, result)

        path.pop()
            