PsiElement (PsiElement nextComment) { PsiElement elementToCheck = nextComment; while (true) { final PsiElement sibling = elementToCheck.getPrevSibling(); if (sibling == null) { return null; } if (sibling.getText().trim().replace("\n", "").isEmpty()) { elementToCheck = sibling; } else { return sibling; } } }