SpecialFirstIterationLoop (@NotNull TerminalBlock terminalBlock, StreamApiMigrationInspection.CountingLoopSource countingLoopSource) { PsiVariable loopVar = countingLoopSource.getVariable(); PsiLocalVariable loopLocalVar = tryCast(loopVar, PsiLocalVariable.class); if (loopLocalVar == null) return null; List<PsiStatement> statements = List.of(terminalBlock.getStatements()); int index = getSingleStatementIndex(statements, statement -> statement instanceof PsiIfStatement); if (index == -1) return null; ThreeState firstIterationThen = isFirstIterationThen(statements.get(index), loopVar); if (firstIterationThen.equals(ThreeState.UNSURE)) return null; return SpecialFirstIterationLoop.extract(firstIterationThen.toBoolean(), index, statements, loopLocalVar); }