public static IntTreeBag union(IntTreeBag b1, IntTreeBag b2){
    IntTreeBag newBag = new IntTreeBag();//creates a new bag
    
    if((b1 == null) || (b2 == null)){
        throw new IllegalArgumentException(" at least one bag is empty");
    }else{
        newBag = (IntTreeBag) b1.clone();
    }
    newBag.addAll(b2);
    
    return newBag;
 }