(root)
return max_len
:type root: TreeNode
    :rtype: int
:type root: TreeNode
    :rtype: int
: type root : TreeNode : rtype : int
def longest_consecutive(root):
    """
    :type root: TreeNode
    :rtype: int
    """
    if root is None:
        return 0
    max_len = 0
    dfs(root, 0, root.val, max_len)
    return max_len
def longest_consecutive ( root ) : if root is None : return 0 max_len = 0 dfs ( root , 0 , root . val , max_len ) return max_len