private static Polygon2D createTree(Polygon2D components[],int low,int high,boolean splitX){
  if (low > high) {
    return null;
  }
  final int mid=(low + high) >>> 1;
  if (low < high) {
    Comparator<Polygon2D> comparator;
    if (splitX) {
      comparator=null;
    }
 else {
      comparator=null;
    }
    ArrayUtil.select(components,low,high + 1,mid,comparator);
  }
  Polygon2D newNode=components[mid];
  newNode.splitX=splitX;
  newNode.left=createTree(components,low,mid - 1,!splitX);
  newNode.right=createTree(components,mid + 1,high,!splitX);
  if (newNode.left != null) {
    newNode.maxX=Math.max(newNode.maxX,newNode.left.maxX);
    newNode.maxY=Math.max(newNode.maxY,newNode.left.maxY);
  }
  if (newNode.right != null) {
    newNode.maxX=Math.max(newNode.maxX,newNode.right.maxX);
    newNode.maxY=Math.max(newNode.maxY,newNode.right.maxY);
  }
  return newNode;
}

private static Polygon2D createTree ( Polygon2D components [ ] , int low , int high , boolean splitX ) { if ( low > high ) { return null ; } final int mid = ( low + high ) > > > 1 ; if ( low < high ) { Comparator < Polygon2D > comparator ; if ( splitX ) { comparator = null ; } else { comparator = null ; } ArrayUtil . select ( components , low , high + 1 , mid , comparator ) ; } Polygon2D newNode = components [ mid ] ; newNode . splitX = splitX ; newNode . left = createTree ( components , low , mid - 1 , ! splitX ) ; newNode . right = createTree ( components , mid + 1 , high , ! splitX ) ; if ( newNode . left != null ) { newNode . maxX = Math . max ( newNode . maxX , newNode . left . maxX ) ; newNode . maxY = Math . max ( newNode . maxY , newNode . left . maxY ) ; } if ( newNode . right != null ) { newNode . maxX = Math . max ( newNode . maxX , newNode . right . maxX ) ; newNode . maxY = Math . max ( newNode . maxY , newNode . right . maxY ) ; } return newNode ; }
creates tree from sorted components ( with range low and high inclusive )
