def construct_tree_from_dict(data: Union[Dict, List], node_name: str = None):
    """
    Convert Dictionary into Tree

    Example:
        input(dict)

            {
                "menu": [
                    {"name" : ["cake"], "count" : ["2"]},
                    {"name" : ["juice"], "count" : ["1"]},
                ]
            }

        output(tree)
                                 <root>
                                   |
                                 menu
                                /    \
                         <subtree>  <subtree>
                        /      |     |      \
                     name    count  name    count
                    /         |     |         \
              <leaf>cake  <leaf>2  <leaf>juice  <leaf>1
     """
    if node_name is None:
        node_name = "<root>"

    node = Node(node_name)

    if isinstance(data, dict):
        for key, value in data.items():
            kid_node = construct_tree_from_dict(value, key)
            node.addkid(kid_node)
    elif isinstance(data, list):
        if all(isinstance(item, dict) for item in data):
            for item in data:
                kid_node = construct_tree_from_dict(
                    item,
                    "<subtree>",
                )
                node.addkid(kid_node)
        else:
            for item in data:
                node.addkid(Node(f"<leaf>{item}"))
    else:
        raise Exception(data, node_name)
    return node

    Convert Dictionary into Tree

    Example:
        input(dict)

            {
                "menu": [
                    {"name" : ["cake"], "count" : ["2"]},
                    {"name" : ["juice"], "count" : ["1"]},
                ]
            }

        output(tree)
                                 <root>
                                   |
                                 menu
                                /                             <subtree>  <subtree>
                        /      |     |                           name    count  name    count
                    /         |     |                       <leaf>cake  <leaf>2  <leaf>juice  <leaf>1
     
vlmeval/dataset/utils/ccocr_evaluator/kie_evaluator.py