def METHOD_NAME(self, container):
    text = container.document.get_string(self.strings_class, self.key)
    if isinstance(text, StyledText):
        text.parent = self
        yield text
    else:
        yield SingleStyledText(text, parent=self)