private static long findUniqueValueFromBranch ( CharSequence chars , int pos , int length , long uniqueValue ) { while ( length > kMaxBranchLinearSubNodeLength ) { ++ pos ; // ignore the comparison unit uniqueValue = findUniqueValueFromBranch ( chars , jumpByDelta ( chars , pos ) , length >> 1 , uniqueValue ) ; if ( uniqueValue == 0 ) { return 0 ; } length = length - ( length >> 1 ) ; pos = skipDelta ( chars , pos ) ; } do { ++ pos ; // ignore a comparison unit // handle its value int node = chars . charAt ( pos ++ ) ; boolean isFinal = ( node & kValueIsFinal ) != 0 ; node &= 0x7fff ; int value = readValue ( chars , pos , node ) ; pos = skipValue ( pos , node ) ; if ( isFinal ) { if ( uniqueValue != 0 ) { if ( value != ( int ) ( uniqueValue >> 1 ) ) { return 0 ; } } else { uniqueValue = ( ( long ) value << 1 ) | 1 ; } } else { uniqueValue = findUniqueValue ( chars , pos + value , uniqueValue ) ; if ( uniqueValue == 0 ) { return 0 ; } } } while ( -- length > 1 ) ; // ignore the last comparison byte return ( ( long ) ( pos + 1 ) << 33 ) | ( uniqueValue & 0x1ffffffff L ) ; }
On return if not 0 then bits 63 .. 33 contain the updated non - negative pos .