human
Can you provide a the Python code you requested given the following:
Complete the below
def commit_tree(object_store, blobs):

    ''''Commit a new tree.
    :param object_store: Object store to add trees to
    :param blobs: Iterable over blob path, sha, mode entries
    :return: SHA1 of the created tree.'
    '''
assistant
#Here is the Python code you requested.
    trees = {'': {}}
    def add_tree(path):
        if (path in trees):
            return trees[path]
        (dirname, basename) = pathsplit(path)
        t = add_tree(dirname)
        assert isinstance(basename, bytes)
        newtree = {}
        t[basename] = newtree
        trees[path] = newtree
        return newtree
    for (path, sha, mode) in blobs:
        (tree_path, basename) = pathsplit(path)
        tree = add_tree(tree_path)
        tree[basename] = (mode, sha)
    def build_tree(path):
        tree = Tree()
        for (basename, entry) in trees[path].items():
            if isinstance(entry, dict):
                mode = stat.S_IFDIR
                sha = build_tree(pathjoin(path, basename))
            else:
                (mode, sha) = entry
            tree.add(basename, mode, sha)
        object_store.add_object(tree)
        return tree.id
    return build_tree('')