def __build_parser_for_fileobject_and_desiredtype(self, obj_on_filesystem: PersistedObject, object_typ: Type[T],
                                                      logger: Logger = None) -> Parser:
        """
        Builds from the registry, a parser to parse object obj_on_filesystem as an object of type object_type.

        To do that, it iterates through all registered parsers in the list in reverse order (last inserted first),
        and checks if they support the provided object format (single or multifile) and type.
        If several parsers match, it returns a cascadingparser that will try them in order.

        :param obj_on_filesystem:
        :param object_typ:
        :param logger:
        :return:
        """

        # first remove any non-generic customization
        object_type = get_base_generic_type(object_typ)

        # find all matching parsers for this
        matching, no_type_match_but_ext_match, no_ext_match_but_type_match, no_match = \
            self.find_all_matching_parsers(strict=self.is_strict, desired_type=object_type,
                                           required_ext=obj_on_filesystem.ext)
        matching_parsers = matching[0] + matching[1] + matching[2]

        if len(matching_parsers) == 0:
            # No match. Do we have a close match ? (correct type, but not correct extension ?)
            if len(no_ext_match_but_type_match) > 0:
                raise NoParserFoundForObjectExt.create(obj_on_filesystem, object_type,
                                                       set([ext_ for ext_set in
                                                        [p.supported_exts for p in no_ext_match_but_type_match]
                                                        for ext_ in ext_set]))
            else:
                # no, no match at all
                raise NoParserFoundForObjectType.create(obj_on_filesystem, object_type,
                                                        set([typ_ for typ_set in
                                                        [p.supported_types for p in no_type_match_but_ext_match]
                                                        for typ_ in typ_set]))

        elif len(matching_parsers) == 1:
            # return the match directly
            return matching_parsers[0]
        else:
            # return a cascade of all parsers, in reverse order (since last is our preferred one)
            # print('----- WARNING : Found several parsers able to parse this item. Combining them into a cascade.')
            return CascadingParser(list(reversed(matching_parsers)))