question: private boolean equalsFragments ( ByteString other ) { int thisOffset = 0 ; Iterator < LiteralByteString > thisIter = new PieceIterator ( this ) ; LiteralByteString thisString = thisIter . next ( ) ; int thatOffset = 0 ; Iterator < LiteralByteString > thatIter = new PieceIterator ( other ) ; LiteralByteString thatString = thatIter . next ( ) ; int pos = 0 ; while ( true ) { int thisRemaining = thisString . size ( ) - thisOffset ; int thatRemaining = thatString . size ( ) - thatOffset ; int bytesToCompare = Math . min ( thisRemaining , thatRemaining ) ; boolean stillEqual = ( thisOffset == 0 ) ? thisString . equalsRange ( thatString , thatOffset , bytesToCompare ) : thatString . equalsRange ( thisString , thisOffset , bytesToCompare ) ; if ( ! stillEqual ) { return false ; } pos += bytesToCompare ; if ( pos >= totalLength ) { if ( pos == totalLength ) { return true ; } throw new IllegalStateException ( ) ; } if ( bytesToCompare == thisRemaining ) { thisOffset = 0 ; thisString = thisIter . next ( ) ; } else { thisOffset += bytesToCompare ; } if ( bytesToCompare == thatRemaining ) { thatOffset = 0 ; thatString = thatIter . next ( ) ; } else { thatOffset += bytesToCompare ; } } }
target:  Determines if this string is equal to another of the same length by iterating over the leaf nodes. On each step of the iteration, the overlapping segments of the leaves are compared.