ElseIf (@NotNull PsiIfStatement ifStatement, PsiStatement @NotNull [] thenStatements) { PsiStatement elseBranch = ifStatement.getElseBranch(); if (ifStatement.getCondition() == null) return null; PsiIfStatement elseIf = tryCast(ControlFlowUtils.stripBraces(elseBranch), PsiIfStatement.class); if (elseIf == null) return null; PsiExpression elseIfCondition = elseIf.getCondition(); if (elseIfCondition == null) return null; PsiStatement elseIfThenBranch = elseIf.getThenBranch(); if(elseIfThenBranch == null) return null; PsiStatement[] elseIfThen = ControlFlowUtils.unwrapBlock(elseIfThenBranch); PsiStatement elseIfElseBranch = elseIf.getElseBranch(); if (elseIfElseBranch == null) return null; if (elseIfThen.length == thenStatements.length) { LocalEquivalenceChecker equivalence = getChecker(thenStatements, elseIfThen); if (branchesAreEquivalent(thenStatements, Arrays.asList(elseIfThen), equivalence)) { return new ElseIf(elseBranch, elseIfElseBranch, elseIfThenBranch, elseIfCondition, equivalence.mySubstitutionTable, false); } } PsiStatement[] elseIfElse = ControlFlowUtils.unwrapBlock(elseIfElseBranch); if (elseIfElse.length == thenStatements.length) { LocalEquivalenceChecker equivalence = getChecker(thenStatements, elseIfThen); if (branchesAreEquivalent(thenStatements, Arrays.asList(elseIfElse), equivalence)) { return new ElseIf(elseBranch, elseIfThenBranch, elseIfElseBranch, elseIfCondition, equivalence.mySubstitutionTable, true); } } return null; }