def number_of_nodes(tree):
    """Return the number of nodes of tree."""
    if tree.is_empty():
        return 0
    else:
        return 1\
               + number_of_nodes(tree.left_child())\
               + number_of_nodes(tree.right_child())