'Apply the filter.
Accepts either an entity or a reference to avoid the need to extract keys
from entities when we have a list of entities (which is a common case).
Args:
entity_or_reference: Either an entity_pb.EntityProto or
entity_pb.Reference.'

def __call__(self, entity_or_reference):

    if isinstance(entity_or_reference, entity_pb.Reference):
        key = entity_or_reference
    elif isinstance(entity_or_reference, entity_pb.EntityProto):
        key = entity_or_reference.key()
    else:
        raise datastore_errors.BadArgumentError(('entity_or_reference    argument    must    be    an    entity_pb.EntityProto    ' + ('or    entity_pb.Reference    (%r)' % entity_or_reference)))
    return ((key.app() == self.__app) and (key.name_space() == self.__namespace) and ((not self.__kind) or (key.path().element_list()[(-1)].type() == self.__kind)) and ((not self.__path) or (key.path().element_list()[0:len(self.__path)] == self.__path)))
