Return a copy of the ``fieldsets`` list with the new field(s) inserted.

    Args:
        fieldsets (list): The original ``fieldsets`` list.
        fieldset_index_or_name (int or str): The name of the reference fieldset, or directly its numeric index.
        new_fields (str or list of str): The field(s) to insert in the ``fieldsets`` list.
        field_index_or_name (int or str): The name of the reference field, or directly its numeric index.
                                          Default: None (=append).
        after (bool): Whether to insert the new elements before or after the reference element. Default: True.

    Returns:
        (list) A copy of the original ``fieldsets`` list containing the new field(s).

def insert_fields_in_fieldsets(fieldsets, fieldset_index_or_name, new_fields, field_index_or_name=None, after=True):
    """
    Return a copy of the ``fieldsets`` list with the new field(s) inserted.

    Args:
        fieldsets (list): The original ``fieldsets`` list.
        fieldset_index_or_name (int or str): The name of the reference fieldset, or directly its numeric index.
        new_fields (str or list of str): The field(s) to insert in the ``fieldsets`` list.
        field_index_or_name (int or str): The name of the reference field, or directly its numeric index.
                                          Default: None (=append).
        after (bool): Whether to insert the new elements before or after the reference element. Default: True.

    Returns:
        (list) A copy of the original ``fieldsets`` list containing the new field(s).
    """
    fieldset_index = get_fieldset_index(fieldsets, fieldset_index_or_name)
    fieldset_fields = fieldsets[fieldset_index][1]["fields"]

    try:
        field_index = get_list_index(fieldset_fields, field_index_or_name)
    except ValueError:
        field_index = None

    to_return = deepcopy(fieldsets)
    to_return[fieldset_index][1]["fields"] = list_insert(fieldset_fields, new_fields, field_index, after=after)
    return to_return