ImplicitElse (PsiStatement @NotNull [] thenBranch, PsiStatement @NotNull [] elseBranch, @NotNull PsiIfStatement ifStatement) { if (elseBranch.length != 0 || thenBranch.length == 0) return null; PsiStatement lastThenStatement = thenBranch[thenBranch.length - 1]; String jumpKeyword = null; boolean basicJumpStatement = false; if (lastThenStatement instanceof PsiReturnStatement) { jumpKeyword = PsiKeyword.RETURN; basicJumpStatement = ((PsiReturnStatement)lastThenStatement).getReturnValue() == null; } else if (lastThenStatement instanceof PsiContinueStatement) { jumpKeyword = PsiKeyword.CONTINUE; basicJumpStatement = ((PsiContinueStatement)lastThenStatement).getLabelIdentifier() == null; } if (jumpKeyword == null) return null; ImplicitElseData implicitElse = getIfWithImplicitElse(ifStatement, thenBranch, jumpKeyword, basicJumpStatement); if (implicitElse == null) return null; if (implicitElse.myImplicitElseStatements.isEmpty()) return null; if (implicitElse.myImplicitElseStatements.size() == 1) { PsiStatement statement = implicitElse.myImplicitElseStatements.get(0); if (statement instanceof PsiReturnStatement) { if (((PsiReturnStatement)statement).getReturnValue() == null) return null; } } List<PsiStatement> elseStatements = implicitElse.myImplicitElseStatements; Set<PsiLocalVariable> variables = new HashSet<>(); List<PsiStatement> thenStatements = new ArrayList<>(Arrays.asList(thenBranch)); addLocalVariables(variables, thenStatements); addLocalVariables(variables, implicitElse.myImplicitElseStatements); if (!branchesAreEquivalent(thenBranch, elseStatements, new LocalEquivalenceChecker(variables))) return null; return new ImplicitElse(implicitElse.myIfWithImplicitElse); }