private void deserializeStubList(StubBase<?> root,
                                   ObjectStubSerializer<?, ? extends Stub> rootType,
                                   StubInputStream inputStream,
                                   FileLocalStringEnumerator storage,
                                   @NotNull SerializationState state)
    throws IOException, SerializerNotFoundException {
    int stubCount = DataInputOutputUtil.readINT(inputStream);
    LazyStubList stubList = new LazyStubList(stubCount, root, rootType);

    MostlyUShortIntList parentsAndStarts = new MostlyUShortIntList(stubCount * 2);
    BitSet allStarts = new BitSet();

    new Object() {
      int currentIndex = 1;
      private void deserializeStub(int parentIndex) throws IOException, SerializerNotFoundException {
        int index = currentIndex;
        currentIndex++;

        int serializerId = DataInputOutputUtil.readINT(inputStream);
        ObjectStubSerializer<?, Stub> serializer = getClassByIdLocal(serializerId, null, state);

        int start = serializer instanceof EmptyStubSerializer ? 0 : DataInputOutputUtil.readINT(inputStream);

        allStarts.set(start);

        addStub(parentIndex, index, start, (IElementType)serializer);
        if (!serializer.isAlwaysLeaf(root)) {
          deserializeChildren(index);
        }
      }

      private void addStub(int parentIndex, int index, int start, IElementType type) {
        parentsAndStarts.add(parentIndex);
        parentsAndStarts.add(start);
        stubList.addLazyStub(type, index, parentIndex);
      }

      private void deserializeChildren(int parentIndex) throws IOException, SerializerNotFoundException {
        int childrenCount = DataInputOutputUtil.readINT(inputStream);
        stubList.prepareForChildren(parentIndex, childrenCount);
        for (int i = 0; i < childrenCount; i++) {
          deserializeStub(parentIndex);
        }
      }

      void deserializeRoot() throws IOException, SerializerNotFoundException {
        addStub(0, 0, 0, (IElementType)rootType);
        deserializeChildren(0);
      }
    }.deserializeRoot();
    byte[] serializedStubs = readByteArray(inputStream);
    stubList.setStubData(new LazyStubData(storage, parentsAndStarts, serializedStubs, allStarts));
  }
private void deserializeStubList(StubBase<?> root,
                                   ObjectStubSerializer<?, ? extends Stub> rootType,
                                   StubInputStream inputStream,
                                   FileLocalStringEnumerator storage,
                                   @NotNull SerializationState state)