def merge_groupby_dicts_inplace(left, right):
    """ Merges one internal groupby dictionary (right) into another one (left) and returns
    the merging result. Used for aggregating partial dicts into single result. """

    if not right:
        return left

    for key, right_group_list in right.items():
        left_group_list = left.get(key)
        if left_group_list is None:
            left[key] = right_group_list
        else:
            left_group_list.extend(right_group_list)

    return left