def _build_plain_hierarchy(hierarchy, skip_root=False):
    """Expands tree hierarchy representation to parent-child dictionary.

    Args:
        hierarchy: labels hierarchy
        skip_root (False): if true skips root from the processing (done for the case when all
            classes under hierarchy are collected under virtual node)

    Returns:
        a tuple of:

        -   ``keyed_parent``: dictionary of parent - all its children nodes
        -   ``keyed_child``: dictionary of children - all its parent node
        -   ``children``: all children of the current node
    """
    all_children = set([])
    all_keyed_parent = {}
    all_keyed_child = {}

    if "Subcategory" in hierarchy:
        for node in hierarchy["Subcategory"]:
            keyed_parent, keyed_child, children = _build_plain_hierarchy(node)

            # Update is not done through dict.update() since some children have
            # multiple parents in the hierarchy
            _update_dict(all_keyed_parent, keyed_parent)
            _update_dict(all_keyed_child, keyed_child)
            all_children.update(children)

    if not skip_root:
        all_keyed_parent[hierarchy["LabelName"]] = deepcopy(all_children)
        all_children.add(hierarchy["LabelName"])
        for child, _ in all_keyed_child.items():
            all_keyed_child[child].add(hierarchy["LabelName"])

        all_keyed_child[hierarchy["LabelName"]] = set([])

    return all_keyed_parent, all_keyed_child, all_children
Expands tree hierarchy representation to parent-child dictionary.

    Args:
        hierarchy: labels hierarchy
        skip_root (False): if true skips root from the processing (done for the case when all
            classes under hierarchy are collected under virtual node)

    Returns:
        a tuple of:

        -   ``keyed_parent``: dictionary of parent - all its children nodes
        -   ``keyed_child``: dictionary of children - all its parent node
        -   ``children``: all children of the current node
    
fiftyone/utils/eval/openimages.py