List<PsiElement> (PsiFile file) { final List<PsiElement> result = new ArrayList<>(); file.accept(new XmlRecursiveElementVisitor(true) { @Override public void visitXmlTag(@NotNull XmlTag tag) { if (isAcceptableTagType(tag)) result.add(tag); super.visitXmlTag(tag); } @Override public void visitComment(@NotNull final PsiComment comment) { if (isDeclarationComment(comment)) result.add(comment); super.visitComment(comment); } @Override public void visitXmlComment(final @NotNull XmlComment comment) { if (isDeclarationComment(comment)) result.add(comment); super.visitComment(comment); } }); return result; }