code: def _to_legacy_path(dict_path):
      
      elements = []
      for part in dict_path:
          element_kwargs = {"type": part["kind"]}
          if "id" in part:
              element_kwargs["id"] = part["id"]
          elif "name" in part:
              element_kwargs["name"] = part["name"]
          element = _app_engine_key_pb2.Path.Element(**element_kwargs)
          elements.append(element)
  
      return _app_engine_key_pb2.Path(element=elements)
docs: Convert a tuple of ints and strings in a legacy "Path".
  
      .. note:
  
          This assumes, but does not verify, that each entry in
          ``dict_path`` is valid (i.e. doesn't have more than one
          key out of "name" / "id").
  
      :type dict_path: lsit
      :param dict_path: The "structured" path for a key, i.e. it
                        is a list of dictionaries, each of which has
                        "kind" and one of "name" / "id" as keys.
  
      :rtype: :class:`._app_engine_key_pb2.Path`
      :returns: The legacy path corresponding to ``dict_path``.