def length(tree):
    """
    Count the total number of the tree nodes.
    :param tree: a tree node
    :return: the total of nodes in the subtree
    """
    if tree:
        n_nodes = length(tree.left)
        n_nodes += length(tree.right)
        n_nodes += 1
        return n_nodes
    return 0