List<PsiElement> (@NotNull PsiElement root, int startOffset, int endOffset, boolean includeAllParents) { PsiElement commonParent = findCommonParent(root, startOffset, endOffset); if (commonParent == null) return new ArrayList<>(); List<PsiElement> list = getElementsToHighlight(commonParent, startOffset, endOffset); PsiElement parent = commonParent; while (parent != null && parent != root) { list.add(parent); parent = includeAllParents ? parent.getParent() : null; } list.add(root); return list; }