def companies(self): rels = ContactCompany.query(ancestor=self.key.parent()).filter( ContactCompany.contact == self.key) keys = [rel.company for rel in rels] return ndb.get_multi(keys)