def METHOD_NAME(service_id, template_type=None):
    if template_type is not None:
        return (
            Template.query.filter_by(
                service_id=service_id,
                template_type=template_type,
                hidden=False,
                archived=False,
            )
            .order_by(
                asc(Template.name),
                asc(Template.template_type),
            )
            .all()
        )
    return (
        Template.query.filter_by(service_id=service_id, hidden=False, archived=False)
        .order_by(
            asc(Template.name),
            asc(Template.template_type),
        )
        .all()
    )