PsiComment (@NotNull PsiElement element) { List<List<PsiComment>> commentBlocks = PyPsiUtils.getPrecedingCommentBlocks(element); if (commentBlocks.isEmpty()) return null; List<PsiComment> firstBlock = commentBlocks.get(0); PsiComment firstComment = firstBlock.get(0); if (firstComment.getPrevSibling() != null) { return firstComment; } PsiComment lastCommentFirstBlock = firstBlock.get(firstBlock.size() - 1); if (PyUtil.isNoinspectionComment(lastCommentFirstBlock)) { return lastCommentFirstBlock; } if (commentBlocks.size() == 1) return null; return ContainerUtil.getFirstItem(commentBlocks.get(1)); }