void () { final BeforeAfter<List<String>> lastStep = myPatchSteps.get(myPatchSteps.size() - 1); final List<String> before = lastStep.getBefore(); final List<String> after = lastStep.getAfter(); int cntBefore = before.size() - 1; int cntAfter = after.size() - 1; for (; cntBefore >= 0 && cntAfter > 0; cntBefore--, cntAfter--) { if (! before.get(cntBefore).equals(after.get(cntAfter))) break; } // typically only 1 line int cutSame = before.size() - 1 - cntBefore; for (int i = 0; i < cutSame; i++) { before.remove(before.size() - 1); after.remove(after.size() - 1); } }