def visited(self, relation_name: str) -> bool:
        """
        Checks if given relation was already visited.

        Relation was visited if it's name is in current node children.

        Relation was visited if one of the parent node had the same Model class

        :param relation_name: name of relation
        :type relation_name: str
        :return: result of the check
        :rtype: bool
        """
        target_model = self.node_class.ormar_config.model_fields[relation_name].to
        if self.parent_node:
            node = self
            while node.parent_node:
                node = node.parent_node
                if node.node_class == target_model:
                    return True
        return False

        Checks if given relation was already visited.

        Relation was visited if it's name is in current node children.

        Relation was visited if one of the parent node had the same Model class

        :param relation_name: name of relation
        :type relation_name: str
        :return: result of the check
        :rtype: bool
        
ormar/models/traversible.py