Integer (@NotNull Side touchSide, int equalForward, int equalBackward, @NotNull Range range1, @NotNull Range range2, int threshold) { Side nonTouchSide = touchSide.other(); List<? extends Line> nonTouchLines = nonTouchSide.select(myData1, myData2); int changeStart = nonTouchSide.select(range1.end1, range1.end2); int changeEnd = nonTouchSide.select(range2.start1, range2.start2); int shiftForward = findNextUnimportantLine(nonTouchLines, changeStart, equalForward + 1, threshold); int shiftBackward = findPrevUnimportantLine(nonTouchLines, changeEnd - 1, equalBackward + 1, threshold); return getShift(shiftForward, shiftBackward); }