def METHOD_NAME(cls, reference):
    '''Returns a resource object referenced by its name or id.'''
    if not reference:
        return None
    resource = meta.Session.query(cls).METHOD_NAME(reference)
    if resource is None:
        resource = cls.by_name(reference)
    return resource