anchor.diff:          elements.ToArray ()
   
       //
  +    let toSet (measurer : IMeasurer<_>) (tree : Diet<'T>) =
  +        (measurer, Set.empty, tree)
  +        |||> fold (fun set el ->
  +            Set.add el set)
  +
  +    // TEMP
  +    let internal ensureAllElementsUnique (measurer : IMeasurer<_>) (tree : Diet<'T>) =
  +        let uniqueElementCount =
  +            toSet measurer tree
  +            |> Set.count
  +
  +        let actualElementCount = count measurer tree
  +        Debug.Assert (
  +            (actualElementCount = uniqueElementCount),
  +            sprintf "Incorrectly-formed DIET found: contains %i elements, but only %i unique elements." actualElementCount uniqueElementCount)
  +        tree
  +
  +    //
       let forall (predicate : 'T -> bool) (measurer : IMeasurer<_>) (t : Diet<'T>) =
           // OPTIMIZE : Rewrite this to short-circuit and return early
           // if we find a non-matching element.
  
positive.code:                     AvlTree.Node (newRange, left, right, h)
                      |> addRange measurer newRange'
  
      /// Computes the union of the two sets.
      let rec union (measurer : IMeasurer<_>) (input : Diet<_>) (stream : Diet<_>) : Diet<'T> =
          let inline compare a b =
              measurer.Compare (a, b)
  
          let rec union' (input : Diet<_>) limit head (stream : Diet<_>) =
              match head with
              | None ->
                  input, None, AvlTree.Empty
              | Some (rangeXY : Range<_>) ->
                  match input with
                  | AvlTree.Empty ->
                      (AvlTree.Empty, head, stream)
                  | AvlTree.Node (rangeAB, left, right, _) ->
                      let left', head, stream =
                          if compare rangeXY.MinValue rangeAB.MinValue < 0 then
                              union' left (Some (measurer.Previous rangeAB.MinValue)) head stream
                          else (left, head, stream)
  
                      union_helper left' rangeAB right limit head stream
  
          and union_helper left (rangeAB : Range<_>) right limit head stream =
              match head with
              | None ->
                  (AvlTree.join rangeAB left right, None, AvlTree.Empty)
              | Some (rangeXY : Range<_>) ->
                  let greater_limit z =
                      match limit with
                      | None -> false
                      | Some u ->
                          compare z u >= 0
                  
                  if compare rangeXY.MaxValue rangeAB.MinValue < 0 && compare rangeXY.MaxValue (measurer.Previous rangeAB.MinValue) < 0 then
                      let left' = addRange measurer rangeXY left
                      let head, stream = AvlTree.tryExtractMin measurer stream
                      union_helper left' rangeAB right limit head stream
  
                  elif compare rangeXY.MinValue rangeAB.MaxValue > 0 && compare rangeXY.MinValue (measurer.Next rangeAB.MaxValue) > 0 then
                      let right', head, stream = union' right limit head stream
                      (AvlTree.join rangeAB left right', head, stream)
                  elif compare rangeAB.MaxValue rangeXY.MaxValue >= 0 then
                      let head, stream = AvlTree.tryExtractMin measurer stream
                      let newRange = Range (min measurer rangeAB.MinValue rangeXY.MinValue, rangeAB.MaxValue)
                      union_helper left newRange right limit head stream
                  elif greater_limit rangeXY.MaxValue then
                      let newRange = Range (min measurer rangeAB.MinValue rangeXY.MinValue, rangeXY.MaxValue)
                      (left, Some newRange, stream)
                  else
                      let (right', head, stream) =
                          let newRange = Range (min measurer rangeAB.MinValue rangeXY.MinValue, rangeXY.MaxValue)
                          union' right limit (Some newRange) stream
                      (AvlTree.reroot measurer left right', head, stream)
          
          if AvlTree.height stream > AvlTree.height input then
              union measurer stream input
          else
  
negative.code:             AvlTree.singleton rangePQ
          | AvlTree.Node (rangeXY, left, right, _) ->
              if compare rangePQ.MaxValue (measurer.Previous rangeXY.MinValue) < 0 then
                  let left =
                      addRange' measurer rangePQ left
                      |> ensureCorrectlyFormed measurer
  
                  AvlTree.join rangeXY left right
                  |> ensureCorrectlyFormed measurer
  
              elif compare rangePQ.MinValue (measurer.Next rangeXY.MaxValue) > 0 then
                  let right =
                      addRange' measurer rangePQ right
                      |> ensureCorrectlyFormed measurer
                  
                  AvlTree.join rangeXY left right
                  |> ensureCorrectlyFormed measurer
              else
                  let x', left' =
                      if compare rangePQ.MinValue rangeXY.MinValue >= 0 then
                          rangeXY.MinValue, left
                      else
                          find_del_left measurer rangePQ.MinValue left
                          |> ensureCorrectlyFormed2Of2 measurer
  
                  let y', right' =
                      if compare rangePQ.MaxValue rangeXY.MaxValue <= 0 then
                          rangeXY.MaxValue, right
                      else
                          find_del_right measurer rangePQ.MaxValue right
                          |> ensureCorrectlyFormed2Of2 measurer
  
                  let rangeXY' = Range (x', y')
                  AvlTree.join rangeXY' left' right'
                  |> ensureCorrectlyFormed measurer
  
      // TEMP
      let rec addRange (measurer : IMeasurer<_>) rangePQ (tree : Diet<'T>) : Diet<_> =
          addRange' measurer rangePQ tree
          //|> ensureAllElementsUnique measurer
          |> ensureCorrectlyFormed measurer
  
      /// Returns a new set with the given element removed.
      /// No exception is thrown if the set doesn't contain the specified element.
  