private void serializeStubList(@NotNull StubBase<?> root, 
                                 @NotNull StubList stubList,
                                 @NotNull DataOutput out,
                                 AbstractStringEnumerator storage,
                                 @NotNull SerializationState state) throws IOException {
    if (!stubList.isChildrenLayoutOptimal()) {
      throw new IllegalArgumentException("Manually assembled stubs should be normalized before serialization, consider wrapping them into StubTree");
    }

    DataInputOutputUtil.writeINT(out, stubList.size());
    DataInputOutputUtil.writeINT(out, stubList.getChildrenCount(0));

    BufferExposingByteArrayOutputStream tempBuffer = new BufferExposingByteArrayOutputStream();
    ByteArrayInterner interner = new ByteArrayInterner();

    for (int i = 1; i < stubList.size(); i++) {
      StubBase<?> stub = stubList.get(i);
      ObjectStubSerializer<Stub, Stub> serializer = writeSerializerId(stub, out, state);
      if (!(serializer instanceof EmptyStubSerializer)) {
        DataInputOutputUtil.writeINT(out, interner.internBytes(serializeStub(serializer, storage, stub, tempBuffer)));
      }
      int count = stubList.getChildrenCount(stub.id);
      if (!serializer.isAlwaysLeaf(root)) {
        DataInputOutputUtil.writeINT(out, count);
      }
      else {
        if (count != 0) {
          throw new IllegalStateException(
            "Serializer reported that children are not possible, but they are present. Serializer = " +
            serializer.getClass().getName() + "; Children count = " + count);
        }
      }
    }

    writeByteArray(out, interner.joinedBuffer.getInternalBuffer(), interner.joinedBuffer.size());
  }
private void serializeStubList(@NotNull StubBase<?> root, 
                                 @NotNull StubList stubList,
                                 @NotNull DataOutput out,
                                 AbstractStringEnumerator storage,
                                 @NotNull SerializationState state)