private void serializeRoot(StubOutputStream out,
                             Stub root,
                             AbstractStringEnumerator storage,
                             @NotNull SerializationState state) throws IOException {
    serializeSelf(root, out, state);
    if (root instanceof StubBase<?> base) {
      StubList stubList = base.myStubList;
      if (root != stubList.get(0)) {
        throw new IllegalArgumentException("Serialization is supported only for root stubs");
      }
      serializeStubList(base, stubList, out, storage, state);
    }
    else {
      serializeChildren(root, out, state);
    }
  }
private void serializeRoot(StubOutputStream out,
                             Stub root,
                             AbstractStringEnumerator storage,
                             @NotNull SerializationState state)