List<List<PsiComment>> (@NotNull PsiElement element) { List<List<PsiComment>> blocks = new ArrayList<>(); PsiElement anchor = element; do { Pair<List<PsiComment>, PsiElement> blockAndAnchor = getPrecedingCommentsAndAnchor(anchor, true, false); anchor = blockAndAnchor.getSecond(); List<PsiComment> block = blockAndAnchor.getFirst(); if (block.size() != 0 || anchor instanceof PsiComment) { blocks.add(block); } } while (anchor instanceof PsiComment); Collections.reverse(blocks); return blocks; }