def METHOD_NAME(session, tid, id_or_name):
    return session.query(models.File) \
                  .filter(models.File.tid == tid,
                          or_(models.File.id == id_or_name,
                              models.File.name == id_or_name)).one_or_none()