boolean (PsiElement element) { if (!(element instanceof PsiJavaToken token)) { return false; } final PsiElement parent = token.getParent(); if (!(parent instanceof PsiIfStatement ifStatement)) { return false; } if (ErrorUtil.containsError(ifStatement)) { return false; } PsiStatement thenBranch = ifStatement.getThenBranch(); thenBranch = ControlFlowUtils.stripBraces(thenBranch); PsiStatement elseBranch = ifStatement.getElseBranch(); elseBranch = ControlFlowUtils.stripBraces(elseBranch); if (thenBranch == null) { return false; } if (elseBranch != null) { return false; } if (!(thenBranch instanceof PsiIfStatement childIfStatement)) { return false; } return childIfStatement.getElseBranch() == null; }