void (@NotNull SwitchStatement switchStatement, @NotNull PatternContainer patternContainer) { for (Map.Entry<Statement, List<PatternContainer.PatternStatement>> entry : patternContainer.patternsByStatement.entrySet()) { if (entry.getValue().size() == 1) { continue; } Statement currentStatement = entry.getKey(); int indexOf = switchStatement.getCaseStatements().indexOf(currentStatement); if (indexOf < 0) { continue; } List<PatternContainer.PatternStatement> value = entry.getValue(); for (int i = value.size() - 1; i >= 0; i--) { PatternContainer.PatternStatement patternStatement = value.get(i); int duplicatedIndex = switchStatement.duplicateCaseStatement(currentStatement); if (duplicatedIndex < 0) { continue; } switchStatement.replaceStatement(switchStatement.getCaseStatements().get(duplicatedIndex), patternStatement.caseStatement); switchStatement.getCaseEdges().get(duplicatedIndex).forEach(edge -> { edge.setDestination(patternStatement.caseStatement); } ); VarExprent variable = patternStatement.variable(); ArrayList<Exprent> newList = new ArrayList<>(); newList.add(variable); switchStatement.getCaseValues().set(duplicatedIndex, newList); Exprent guard = patternStatement.guard; if (guard != null) { switchStatement.addGuard(patternStatement.caseStatement, guard); } } switchStatement.removeCaseStatement(currentStatement); } }