def _has_ancestor(self, filt):
    if filt.HasField('property_filter'):
      op = filt.property_filter.op
      name = filt.property_filter.property.name
      return (op == googledatastore.PropertyFilter.HAS_ANCESTOR
              and name == datastore_pbs.PROPERTY_NAME_KEY)
    if filt.HasField('composite_filter'):
      if (filt.composite_filter.op
          == googledatastore.CompositeFilter.AND):
        for sub_filter in filt.composite_filter.filters:
          if self._has_ancestor(sub_filter):
            return True
    return False
Determines if a filter includes an ancestor filter.
dataset/ETHPy150Open GoogleCloudPlatform/python-compat-runtime/appengine-compat/exported_appengine_sdk/google/appengine/datastore/cloud_datastore_validator.py/_QueryValidator._has_ancestor