private Region findRegion(int size,Packing packing){
  validate(!VALIDATING || Integer.bitCount(size) == 1);
  Node<Region> currentNode=getRoot();
  Region currentRegion=currentNode.getPayload();
  if (currentRegion == null || (currentRegion.available() & size) == 0) {
    return null;
  }
 else {
    while (true) {
      Node<Region> prefered=packing.prefered(currentNode);
      Region preferedRegion=prefered.getPayload();
      if (preferedRegion != null && (preferedRegion.available() & size) != 0) {
        currentNode=prefered;
        currentRegion=preferedRegion;
      }
 else       if ((currentRegion.availableHere() & size) != 0) {
        return packing.slice(currentRegion,size);
      }
 else {
        Node<Region> fallback=packing.fallback(currentNode);
        Region fallbackRegion=fallback.getPayload();
        if (fallbackRegion != null && (fallbackRegion.available() & size) != 0) {
          currentNode=fallback;
          currentRegion=fallbackRegion;
        }
 else {
          throw new AssertionError();
        }
      }
    }
  }
}

private Region findRegion ( int size , Packing packing ) { validate ( ! VALIDATING || Integer . bitCount ( size ) == 1 ) ; Node < Region > currentNode = getRoot ( ) ; Region currentRegion = currentNode . getPayload ( ) ; if ( currentRegion == null || ( currentRegion . available ( ) & size ) == 0 ) { return null ; } else { while ( true ) { Node < Region > prefered = packing . prefered ( currentNode ) ; Region preferedRegion = prefered . getPayload ( ) ; if ( preferedRegion != null && ( preferedRegion . available ( ) & size ) != 0 ) { currentNode = prefered ; currentRegion = preferedRegion ; } else if ( ( currentRegion . availableHere ( ) & size ) != 0 ) { return packing . slice ( currentRegion , size ) ; } else { Node < Region > fallback = packing . fallback ( currentNode ) ; Region fallbackRegion = fallback . getPayload ( ) ; if ( fallbackRegion != null && ( fallbackRegion . available ( ) & size ) != 0 ) { currentNode = fallback ; currentRegion = fallbackRegion ; } else { throw new AssertionError ( ) ; } } } } }
find a region of the given size .
