anchor.diff:          SetTree.report()
           SetTree.numUnions <- SetTree.numUnions + 1
   #endif
  -        match set2.Tree with 
  -        | SetEmpty -> set1  (* A U 0 = A *)
  -        | _ -> 
  -        match set1.Tree with 
  -        | SetEmpty -> set2  (* 0 U B = B *)
  -        | _ -> Set(set1.Comparer, SetTree.union set1.Comparer  set1.Tree set2.Tree)
  +        if SetTree.isEmpty set2.Tree then set1  (* A U 0 = A *)
  +        else
  +            if SetTree.isEmpty set1.Tree then set2  (* 0 U B = B *)
  +            else Set(set1.Comparer, SetTree.union set1.Comparer set1.Tree set2.Tree)
   
       static member Intersection(a: Set<'T>, b: Set<'T>) : Set<'T>  = 
  -        match b.Tree with 
  -        | SetEmpty -> b  (* A INTER 0 = 0 *)
  -        | _ -> 
  -        match a.Tree with 
  -        | SetEmpty -> a (* 0 INTER B = 0 *)
  -        | _ -> Set(a.Comparer, SetTree.intersection a.Comparer a.Tree b.Tree)
  +        if SetTree.isEmpty b.Tree then b  (* A INTER 0 = 0 *)
  +        else
  +            if SetTree.isEmpty a.Tree then a (* 0 INTER B = 0 *)
  +            else Set(a.Comparer, SetTree.intersection a.Comparer a.Tree b.Tree)
   
       static member Union(sets:seq<Set<'T>>) : Set<'T>  = 
           Seq.fold (fun s1 s2 -> s1 + s2) Set<'T>.Empty sets
  
positive.code:               member __.Dispose() = () }
  
      /// Set comparison.  Note this can be expensive.
      let rec compareStacks (comparer: IComparer<'T>) l1 l2 =
          match l1, l2 with 
          | [], [] ->  0
          | [], _  -> -1
          | _, [] ->  1
          | (SetEmpty  _ :: t1), (SetEmpty    :: t2) -> compareStacks comparer t1 t2
          | (SetOne n1k :: t1), (SetOne n2k :: t2) -> 
               let c = comparer.Compare(n1k, n2k) 
               if c <> 0 then c else compareStacks comparer t1 t2
          | (SetOne n1k :: t1), (SetNode (n2k, SetEmpty, n2r, _) :: t2) -> 
               let c = comparer.Compare(n1k, n2k) 
               if c <> 0 then c else compareStacks comparer (SetEmpty :: t1) (n2r :: t2)
          | (SetNode (n1k, (SetEmpty as emp), n1r, _) :: t1), (SetOne n2k :: t2) -> 
               let c = comparer.Compare(n1k, n2k) 
               if c <> 0 then c else compareStacks comparer (n1r :: t1) (emp :: t2)
          | (SetNode (n1k, SetEmpty, n1r, _) :: t1), (SetNode (n2k, SetEmpty, n2r, _) :: t2) -> 
               let c = comparer.Compare(n1k, n2k) 
               if c <> 0 then c else compareStacks comparer (n1r :: t1) (n2r :: t2)
          | (SetOne n1k :: t1), _ -> 
              compareStacks comparer (SetEmpty :: SetOne n1k :: t1) l2
          | (SetNode (n1k, n1l, n1r, _) :: t1), _ -> 
              compareStacks comparer (n1l :: SetNode (n1k, SetEmpty, n1r, 0) :: t1) l2
          | _, (SetOne n2k :: t2) -> 
              compareStacks comparer l1 (SetEmpty :: SetOne n2k :: t2)
          | _, (SetNode (n2k, n2l, n2r, _) :: t2) -> 
              compareStacks comparer l1 (n2l :: SetNode (n2k, SetEmpty, n2r, 0) :: t2)
  
      let compare comparer s1 s2 = 
          match s1, s2 with 
          | SetEmpty, SetEmpty -> 0
          | SetEmpty, _ -> -1
          | _, SetEmpty -> 1
          | _ -> compareStacks comparer [s1] [s2]
  
      let choose s =
          minimumElement s
  
      let toList s = 
          let rec loop m acc = 
              match m with 
              | SetNode (k, l, r, _) -> loop l (k :: loop r acc)
              | SetOne k ->  k :: acc
              | SetEmpty -> acc
          loop s []
  
      let copyToArray s (arr: _[]) i =
          let mutable j = i 
  
negative.code: 
      static let empty: Set<'T> = 
          let comparer = LanguagePrimitives.FastGenericComparer<'T> 
          Set<'T>(comparer, SetTree.empty)
  
      [<System.Runtime.Serialization.OnSerializingAttribute>]
      member __.OnSerializing(context: System.Runtime.Serialization.StreamingContext) =
  