from typing import OrderedDict


def wlogger_get_leaf(data, group_name_stack):
    """
    Helper function to build wireshark data output

    Args:
      data: input data
      group_name_stack: current tree

    Returns:
        Leaf to build data into

    """
    ret = data
    for group_name in group_name_stack:
        if group_name not in ret.keys():
            ret[group_name] = OrderedDict()

        ret = ret[group_name]
    return ret