def METHOD_NAME(
    self,
    text: bytes,
    entities: List[MessageEntity],
    offset: Optional[int] = None,
    length: Optional[int] = None,
) -> Generator[str, None, None]:
    if offset is None:
        offset = 0
    length = length or len(text)
    for index, entity in enumerate(entities):
        if entity.offset * 2 < offset:
            continue
        if entity.offset * 2 > offset:
            yield self.quote(remove_surrogates(text[offset : entity.offset * 2]))
        start = entity.offset * 2
        offset = entity.offset * 2 + entity.length * 2
        sub_entities = list(
            filter(lambda e: e.offset * 2 < (offset or 0), entities[index + 1 :])
        )
        yield self.apply_entity(
            entity,
            "".join(self.METHOD_NAME(text, sub_entities, offset=start, length=offset)),
        )
    if offset < length:
        yield self.quote(remove_surrogates(text[offset:length]))