void (@NotNull PsiElement element, @NotNull Collection<? super String> result) { if (element instanceof PsiComment) { addCommentText(result, (PsiComment)element); return; } if (element instanceof LeafPsiElement) { return; // optimization } PsiTreeUtil.processElements(element, child -> { if (child instanceof PsiComment) { addCommentText(result, (PsiComment)child); } return true; }); }