code: def to_protobuf(self):
          
          key = _entity_pb2.Key()
          key.partition_id.project_id = self.project
  
          if self.namespace:
              key.partition_id.namespace_id = self.namespace
  
          for item in self.path:
              element = key.path.add()
              if "kind" in item:
                  element.kind = item["kind"]
              if "id" in item:
                  element.id = item["id"]
              if "name" in item:
                  element.name = item["name"]
  
          return key
docs: Return a protobuf corresponding to the key.
  
          :rtype: :class:`.entity_pb2.Key`
          :returns: The protobuf representing the key.