boolean (PsiElement element) { if (!(element instanceof PsiJavaToken token)) { return false; } @NonNls final String text = element.getText(); if (!PsiKeyword.ELSE.equals(text)) { return false; } final PsiElement parent = token.getParent(); if (!(parent instanceof PsiIfStatement ifStatement)) { return false; } final PsiStatement thenBranch = ifStatement.getThenBranch(); final PsiStatement elseBranch = ifStatement.getElseBranch(); if (thenBranch == null) { return false; } if (elseBranch == null) { return false; } if (!(elseBranch instanceof PsiIfStatement)) { return false; } return !ErrorUtil.containsError(ifStatement); }