def METHOD_NAME(self, node):
    if node in self.anchors:
        if self.anchors[node] is None:
            self.anchors[node] = self.generate_anchor(node)
    else:
        self.anchors[node] = None
        if isinstance(node, SequenceNode):
            for item in node.value:
                self.METHOD_NAME(item)
        elif isinstance(node, MappingNode):
            for key, value in node.value:
                self.METHOD_NAME(key)
                self.METHOD_NAME(value)