class Node:

    def __init__(self, x):
        self.val = x
self.left = None
self.right = None

def print_path(root):
    rightpath = []
leftpath = []
path = []
if root is None:
    return []
if root.right is None and root.left is None:
    return [root.val]
elif root.right is not None:
    rightpath = [root.val] + print_path(root.right)
elif root.left is not None:
    leftpath = [root.val] + print_path(root.left)
return argmax(rightpath, leftpath)

def argmax(lst1, lst2):
    return lst1 if len(lst1) > len(lst2) else lst2
root_node = Node('a')
root_node.left = Node('b')
root_node.right = Node('c')
root_node.right.right = Node('f')
print(print_path(root_node))
Print the longest path starting from root in a binary tree