def compose_node(self, parent, index):
    if self.check_event(AliasEvent):
        event = self.get_event()
        alias = event.anchor
        if (alias not in self.anchors):
            raise ComposerError(None, None, ('found undefined alias %r' % utf8(alias)), event.start_mark)
        return self.anchors[alias]
    event = self.peek_event()
    anchor = event.anchor
    if (anchor is not None):
        if (anchor in self.anchors):
            ws = '\nfound duplicate anchor {!r}\nfirst occurence {}\nsecond occurence {}'.format(anchor, self.anchors[anchor].start_mark, event.start_mark)
            warnings.warn(ws, ReusedAnchorWarning)
    self.descend_resolver(parent, index)
    if self.check_event(ScalarEvent):
        node = self.compose_scalar_node(anchor)
    elif self.check_event(SequenceStartEvent):
        node = self.compose_sequence_node(anchor)
    elif self.check_event(MappingStartEvent):
        node = self.compose_mapping_node(anchor)
    self.ascend_resolver()
    return node
def compose_node(self, parent, index):
    if self.check_event(AliasEvent):
        event = self.get_event()
        alias = event.anchor
        if (alias not in self.anchors):
            raise ComposerError(None, None, ('found undefined alias %r' % utf8(alias)), event.start_mark)
        return self.anchors[alias]
    event = self.peek_event()
    anchor = event.anchor
    if (anchor is not None):
        if (anchor in self.anchors):
            ws = '\nfound duplicate anchor {!r}\nfirst occurence {}\nsecond occurence {}'.format(anchor, self.anchors[anchor].start_mark, event.start_mark)
            warnings.warn(ws, ReusedAnchorWarning)
    self.descend_resolver(parent, index)
    if self.check_event(ScalarEvent):
        node = self.compose_scalar_node(anchor)
    elif self.check_event(SequenceStartEvent):
        node = self.compose_sequence_node(anchor)
    elif self.check_event(MappingStartEvent):
        node = self.compose_mapping_node(anchor)
    self.ascend_resolver()
    return node