def convert_format(ori_list: list) -> dict:
    """
    设输入列表长度为n
    时间复杂度 O(n) 遍历两次list,
        1. 构建辅助字典, 实现通过子节点查找父节点时间复杂度为O(1); 初始化子节点
        2. 不断将子节点追加到父节点

    空间复杂度: 需要构建辅助节点dict, 和返回结果dict, 空间复杂度是 O(n)
    """
    tree = {"root": {}}
    revert_dict = dict()
    for n in ori_list:
        # 构造反向键值字典
        revert_dict[n["name"]] = n.get("parent")
        # 初始化子节点
        tree[n["name"]] = {}
    for ele in ori_list:
        name = ele["name"]
        parent = revert_dict.get(name) or "root"
        # 子节点追加到父节点
        tree[parent].update({name: tree.get(name)})
    return tree["root"]