(self, model_fields_tree, header_types)
return most_likely_fields_tree
Remove from model_fields_tree param all the fields and subfields
        that do not match the types in header_types

        :param: list[dict] model_fields_tree: Contains recursively all the importable fields of the target model.
                                              Generated in "get_fields_tree" method.
        :param: list header_types: Contains the extracted fields types of the current header.
                                   Generated in :meth:`_extract_header_types`.
Remove from model_fields_tree param all the fields and subfields
        that do not match the types in header_types
Remove from model_fields_tree param all the fields and subfields that do not match the types in header_types
def _filter_fields_by_types(self, model_fields_tree, header_types):
        """ Remove from model_fields_tree param all the fields and subfields
        that do not match the types in header_types

        :param: list[dict] model_fields_tree: Contains recursively all the importable fields of the target model.
                                              Generated in "get_fields_tree" method.
        :param: list header_types: Contains the extracted fields types of the current header.
                                   Generated in :meth:`_extract_header_types`.
        """
        most_likely_fields_tree = []
        for field in model_fields_tree:
            subfields = field.get('fields')
            if subfields:
                filtered_field = dict(field)  # Avoid modifying fields.
                filtered_field['fields'] = self._filter_fields_by_types(subfields, header_types)
                most_likely_fields_tree.append(filtered_field)
            elif field.get('type') in header_types:
                most_likely_fields_tree.append(field)
        return most_likely_fields_tree
def _filter_fields_by_types ( self , model_fields_tree , header_types ) : most_likely_fields_tree = [ ] for field in model_fields_tree : subfields = field . get ( 'fields' ) if subfields : filtered_field = dict ( field ) # Avoid modifying fields. filtered_field [ 'fields' ] = self . _filter_fields_by_types ( subfields , header_types ) most_likely_fields_tree . append ( filtered_field ) elif field . get ( 'type' ) in header_types : most_likely_fields_tree . append ( field ) return most_likely_fields_tree