def METHOD_NAME(aggs):
    # get all subagg -> agg mapping to later iterate over them
    # e.g. {'subcategory': 'category', 'subtype': 'type'}
    subagg_agg_mapping = {}
    for agg, agg_value in aggs.items():
        if agg_value.get("aggs"):
            for subagg in agg_value["aggs"].keys():
                subagg_agg_mapping[subagg] = agg
    return subagg_agg_mapping