def total_file_count(path):
    """Returns total number of files under specified path.

    The path should be a pathlib.Path instance referring to a file
    or directory. For a file this will return 1. Directories will be
    traversed recursively.
    """
    if path.is_file():
        return 1
    return sum(1 for child in path.glob('**/*') if child.is_file())
