<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def find_by_filename(filename=None, engines=None):
 """ Find a list of template engine classes to render template `filename`. :param filename: Template file name (may be a absolute/relative path) :param engines: Template engines :return: A list of engines support given template file """

    if engines is None:
        engines = ENGINES

    if filename is None:
        return list_engines_by_priority(engines)

    return sorted((e for e in engines if e.supports(filename)),
                  key=operator.methodcaller("priority"))