PsiElement (@NotNull PsiElement element, @NotNull List<? super PsiElement> toExtract) { final TextRange range = element.getTextRange(); final ASTNode startTagNameEnd = XmlChildRole.START_TAG_END_FINDER.findChild(element.getNode()); final ASTNode endTagNameStart = XmlChildRole.CLOSING_TAG_START_FINDER.findChild(element.getNode()); int start = startTagNameEnd != null ? startTagNameEnd.getTextRange().getEndOffset() : range.getStartOffset(); int end = endTagNameStart != null ? endTagNameStart.getTextRange().getStartOffset() : range.getEndOffset(); for (PsiElement child : element.getChildren()) { final TextRange childRange = child.getTextRange(); if (childRange.getStartOffset() >= start && childRange.getEndOffset() <= end) { toExtract.add(child); } } return element; }