ConditionData (@NotNull PsiIfStatement ifStatement, boolean firstIterationThen) { PsiStatement block = firstIterationThen ? ifStatement.getThenBranch() : ifStatement.getElseBranch(); ArrayList<PsiStatement> firstIterationStatements = new ArrayList<>(unwrapBlock(block)); int index = getSingleAssignmentIndex(firstIterationStatements); if (index == -1) return null; PsiStatement assignment = firstIterationStatements.remove(index); PsiExpressionStatement expressionStatement = tryCast(assignment, PsiExpressionStatement.class); if(expressionStatement == null) return null; PsiAssignmentExpression assignmentExpression = tryCast(expressionStatement.getExpression(), PsiAssignmentExpression.class); if(assignmentExpression == null) return null; PsiStatement otherBlock = firstIterationThen ? ifStatement.getElseBranch() : ifStatement.getThenBranch(); List<PsiStatement> otherIterationStatements = unwrapBlock(otherBlock); return firstIterationThen ? new ConditionData(firstIterationStatements, otherIterationStatements, assignmentExpression) : new ConditionData(otherIterationStatements, firstIterationStatements, assignmentExpression); }