private static Pair<Integer,PsiElement> addElementSequence(PsiElement startElement, TextRange range, List<? super PsiElement> targetList) {
    PsiElement currElement = startElement;
    int lastOffset = -1;
    while (currElement != null && (lastOffset = currElement.getTextRange().getEndOffset()) <= range.getEndOffset()) {
      if (!(currElement instanceof OuterLanguageElement)) {
        targetList.add(currElement);
      }
      currElement = currElement.getNextSibling();
    }
    if (currElement != null && currElement.getTextRange().intersects(range)) {
      PsiElement child = currElement.getFirstChild();
      if (child != null) {
        addElementSequence(child, range, targetList);
      }
    }
    return new Pair<>(lastOffset, currElement);
  }
private static Pair<Integer,PsiElement> addElementSequence(PsiElement startElement, TextRange range, List<? super PsiElement> targetList)