private int insertLeaves(int curToken, int lastIdx, @NotNull CompositeElement curNode) {
    lastIdx = Math.min(lastIdx, myLexemeCount);
    while (curToken < lastIdx) {
      ProgressIndicatorProvider.checkCanceled();
      int start = myLexStarts[curToken];
      int end = myLexStarts[curToken + 1];
      if (start < end || myLexTypes[curToken] instanceof ILeafElementType) { // Empty token. Most probably a parser directive like indent/dedent in Python
        IElementType type = myLexTypes[curToken];
        TreeElement leaf = createLeaf(type, start, end);
        curNode.rawAddChildrenWithoutNotifications(leaf);
      }
      curToken++;
    }

    return curToken;
  }
private int insertLeaves(int curToken, int lastIdx, @NotNull CompositeElement curNode)