int (OT[] oldChildren, int oldIndex, NT[] newChildren, int newIndex, int level, int step, // 1 if we go from the start to the end; -1 if we go from the end to the start int maxLength) { int delta = 0; while (delta != maxLength*step) { OT oldChild = oldChildren[oldIndex + delta]; NT newChild = newChildren[newIndex + delta]; CompareResult c11 = looksEqual(oldChild, newChild); if (c11 == CompareResult.DRILL_DOWN_NEEDED) { c11 = textMatch(oldChild, newChild) ? build(oldChild, newChild, level + 1, emptyConsumer()) : CompareResult.NOT_EQUAL; assert c11 != CompareResult.DRILL_DOWN_NEEDED; } if (c11 != CompareResult.EQUAL) { break; } delta += step; } return delta*step; }