def METHOD_NAME(self, template_type, template_folder_id, user, ancestors):
    for item in self.service.get_template_folders(
        template_type,
        template_folder_id,
        user,
    ):
        yield TemplateListFolder(
            item,
            folders=self.service.get_template_folders(template_type, item["id"], user),
            templates=self.service.get_templates(template_type, item["id"]),
            ancestors=ancestors,
            service_id=self.service.id,
        )
        for sub_item in self.METHOD_NAME(template_type, item["id"], user, ancestors + [item]):
            yield sub_item
    for item in self.service.get_templates(template_type, template_folder_id, user):
        yield TemplateListTemplate(
            item,
            ancestors=ancestors,
            service_id=self.service.id,
        )