code: @Override
    public Key getParent() {
      List<PathElement> ancestors = getAncestors();
      if (ancestors.isEmpty()) {
        return null;
      }
      PathElement parent = ancestors.get(ancestors.size() - 1);
      Key.Builder keyBuilder;
      if (parent.hasName()) {
        keyBuilder = Key.newBuilder(getProjectId(), parent.getKind(), parent.getName());
      } else {
        keyBuilder = Key.newBuilder(getProjectId(), parent.getKind(), parent.getId());
      }
      String namespace = getNamespace();
      if (namespace != null) {
        keyBuilder.setNamespace(namespace);
      }
      return keyBuilder.addAncestors(ancestors.subList(0, ancestors.size() - 1)).build();
    }
docs: Returns the key's parent.