docs: public int addDocument(String document) {
      if (root().getNumberOfChildren() >= 0) {
        throw new IllegalStateException("Tree sorting has begun");
      }
      final int index;
      synchronized (this) {
        index = documents.size();
        documents.add(document);
      }
      cursors.addAll(
        IntStream.range(0, document.length() + 1).mapToObj(i -> new CursorData(index, i)).collect(Collectors.toList()));
      nodes.update(0, node -> node.setCursorCount(cursors.length()));
      return index;
    }