def clean_list(self, repeats_list):
    """
    Removes all values in a list that equal '' or 'endrepeat':
    If there are nested lists, it recursively calls itself to search those
    too.
    """
    for j, item in reversed(list(enumerate(repeats_list))):
        if isinstance(item, list):
            item = clean_list(self, item)
        elif item == '':
            repeats_list.pop(j)
        elif item['field_name'] == 'endrepeat':
            repeats_list.pop(j)
    return repeats_list