def _convert_list_of_objs_to_list_of_dicts(list_of_objects):
    """
    Recursively convert a list of objects to a list of dicts.

    This works recursively and is needed because the NLP Textanalyzer
    sometimes gives back a list of non-json-serializable objects, which
    need to be converted to dicts. The list structure has to be kept.

    :param list list_of_objects: List of objects to be converted to
        list of dicts.
    :return list: list of objects or a single one
    """
    if isinstance(list_of_objects, list):
        list_of_subobjects = []
        for sub in list_of_objects:
            list_of_subobjects.append(
                _convert_list_of_objs_to_list_of_dicts(sub))
        return list_of_subobjects
    else:
        return list_of_objects.__dict__