<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def hash_tree(filepath: str) -> str: """Return the hexdigest MD5 hash of file or directory at `filepath`. If file - just hash file content. If directory - walk the directory, and accumulate hashes of all the relative paths + contents of files under the directory. """

    if isfile(filepath):
        return hash_file(filepath)
    if isdir(filepath):
        base_dir = filepath
        md5 = hashlib.md5()
        for root, dirs, files in walk(base_dir):
            dirs.sort()
            for fname in sorted(files):
                filepath = join(root, fname)
                # consistent hashing between POSIX & Windows
                md5.update(relpath(filepath, base_dir)
                           .replace('\\', '/').encode('utf8'))
                acc_hash(filepath, md5)
        return md5.hexdigest()
    return None