from utils.treeNode import TreeNode

class Solution:
    def get_paths(self, node):
        result = []
        if not node:
            return result
        
        self.helper([], node, result)
        return [" -> ".join(path) for path in result]
    
    def helper(self, prefix, node, result):
        if not node.left and not node.right:
            #reached a leaf
            result.append(prefix + [str(node.value)])
            return
        
        if node.left:
            self.helper(prefix + [str(node.value)], node.left, result)

        if node.right:
            self.helper(prefix + [str(node.value)], node.right, result)


node1 = TreeNode(1)
node2 = TreeNode(2)
node3 = TreeNode(3)
node4 = TreeNode(4)
node5 = TreeNode(5)
node6 = TreeNode(6)
node7 = TreeNode(7)

node1.left = node2
node1.right = node3

node2.left = node4
node2.right = node5

node3.left = node6
node6.left = node7

print(node1)
solution = Solution()
print(solution.get_paths(node1))
        
        