def total_size_bytes(path):
    """Returns total size in bytes of specified file or directory.

    The path should be a pathlib.Path instance. It will be traversed
    recursively.
    """
    if path.is_file():
        return path.stat().st_size
    return sum(child.stat().st_size for child
               in path.glob('**/*')
               if child.is_file())