void (List<? extends ExtractionUnit> headCommonParts, int canBeExtractedFromThenTail, int canBeExtractedFromElseTail, int canBeExtractedFromTail, List<? super PsiStatement> tailCommonParts) { if (canBeExtractedFromTail == tailCommonParts.size() && canBeExtractedFromElseTail == canBeExtractedFromThenTail) { // trying to append to tail statements, that may change semantics from head, because in tail they can't change semantics for (int i = headCommonParts.size() - 1; i >= 0; i--) { ExtractionUnit unit = headCommonParts.get(i); PsiStatement thenStatement = unit.getThenStatement(); if (!unit.haveSideEffects() || !unit.isEquivalent()) break; headCommonParts.remove(i); tailCommonParts.add(thenStatement); } } }