def make_valid_mapping(package_leaflets):
    """
    Make sure to have valid mappings from NER (input) to section_content (output)

    In case either input or output - None or empty, make sure the corresponding pair is None

    :param package_leaflets: list, collection of package leaflets
    :return: package_leaflets with valid mappings
    """

    for leaflet in package_leaflets:

        current_leaflet_sections = [leaflet.section1, leaflet.section2,
                                    leaflet.section3, leaflet.section4,
                                    leaflet.section5, leaflet.section6]

        for section_index, current_section in enumerate(current_leaflet_sections):

            # if section_content is None, make sure entity_recognition is None too (can not map NER --> None)
            if current_section.section_content is None:
                current_section.entity_recognition = None
                continue

            # if entity_recognition is None, make sure section_content is None too (can not map from None --> text)
            if current_section.entity_recognition is None:
                current_section.section_content = None
                continue

            # set empty section_content to None, make sure entity_recognition is None too (can not map NER --> None)
            if len(current_section.section_content) == 0:
                current_section.section_content = None
                current_section.entity_recognition = None
                continue

            # set empty NER outputs to None, make sure section_content is None too (can not map from None --> text)
            if len(current_section.entity_recognition) == 0:
                current_section.entity_recognition = None
                current_section.section_content = None
                continue

    return package_leaflets