boolean (@NotNull PsiElement element) { if (isAfterExpression(element) || JavaStringContextType.isStringLiteral(element)) return false; PsiExpressionStatement parent = PsiTreeUtil.getParentOfType(element, PsiExpressionStatement.class, true, PsiCodeBlock.class, PsiLambdaExpression.class); if (parent == null) return false; PsiIfStatement previous = ObjectUtils.tryCast(PsiTreeUtil.skipWhitespacesAndCommentsBackward(parent), PsiIfStatement.class); if (previous == null) return false; PsiStatement elseBranch = previous.getElseBranch(); while (elseBranch instanceof PsiIfStatement) { elseBranch = ((PsiIfStatement)elseBranch).getElseBranch(); } return elseBranch == null; }