def METHOD_NAME(session, selector, filter=None):
    if isinstance(selector, tuple):
        q = session.query(*selector)
    else:
        q = session.query(selector)
    if filter is None:
        return q
    if isinstance(filter, tuple):
        return q.filter(*filter)
    else:
        return q.filter(filter)