def _get_previous_excludable(
        self, prefix: str, field: "ForeignKeyField", shift: int = 1
    ) -> "Excludable":
        """
        Returns excludable related to model previous in chain of models.
        Used to check if current model should be excluded.

        :param prefix: prefix of a current table
        :type prefix: str
        :param field: field with relation
        :type field: ForeignKeyField
        :param shift: how many model back to go - for m2m it's 2 due to through models
        :type shift: int
        :return: excludable for previous model
        :rtype: Excludable
        """
        if prefix not in self._previous_prefixes:
            self._previous_prefixes.append(prefix)
        previous_prefix_ind = self._previous_prefixes.index(prefix)
        previous_prefix = (
            self._previous_prefixes[previous_prefix_ind - shift]
            if previous_prefix_ind > (shift - 1)
            else ""
        )
        return self.excludable.get(field.owner, alias=previous_prefix)

        Returns excludable related to model previous in chain of models.
        Used to check if current model should be excluded.

        :param prefix: prefix of a current table
        :type prefix: str
        :param field: field with relation
        :type field: ForeignKeyField
        :param shift: how many model back to go - for m2m it's 2 due to through models
        :type shift: int
        :return: excludable for previous model
        :rtype: Excludable
        
ormar/queryset/reverse_alias_resolver.py