anchor.diff:      ///O(min(n,W)). Lookup and update. Credit: Haskell.org
       let rec updateTryFindWithKey f k t =
           match t with
  -        | Bin(p, m, l, r) when nomatch k p m -> (None, t)
  -        | Bin(p, m, l, r) when zero k m ->
  -            let (found, l) = updateTryFindWithKey f k l
  -            (found, bin p m l r)
           | Bin(p, m, l, r) ->
  -            let (found, r) = updateTryFindWithKey f k r
  -            (found, bin p m l r)
  -        | Tip(ky, y) when k = ky ->
  -            match f k y with
  -            | Some y' -> (Some y, Tip(ky, y'))
  -            | None -> (Some y, Nil)
  -        | Tip(ky, _) -> (None, t)
  -        | Nil -> (None, Nil)
  +            if nomatch k p m then
  +                (None, t)
  +            elif zero k m then
  +                let (found, l) = updateTryFindWithKey f k l
  +                (found, bin p m l r)   
  +            else
  +                let (found, r) = updateTryFindWithKey f k r
  +                (found, bin p m l r)
  +        | Tip(ky, y) ->
  +            if k = ky then
  +                match f k y with
  +                | Some y' -> (Some y, Tip(ky, y'))
  +                | None -> (Some y, Nil)
  +            else
  +                (None, t)
  +        | _ -> (None, Nil)
   
       ///O(log n). The expression (alter f k map) alters the value x at k, or absence thereof. alter can be used to insert, delete, or update a value in an intmap. Credit: Haskell.org
       let rec alter f k t =
           match t with
  -        | Bin(p, m, l, r) when nomatch k p m ->
  -            match f None with
  -            | None -> t
  -            | Some x -> join k (Tip(k, x)) p t
  -        | Bin(p, m, l, r) when zero k m -> bin p m (alter f k l) r
  -        | Bin(p, m, l, r) -> bin p m l (alter f k r)
  -        | Tip(ky, y) when k = ky ->
  -            match f (Some y) with
  -            | Some x -> Tip(ky, x)
  -            | None -> Nil
  -        | Tip(ky, y) ->
  -            match f None with
  -            | Some x -> join k (Tip(k, x)) ky t
  -            | None -> t
  -        | Nil ->
  +        | Bin(p, m, l, r) ->
  +            if nomatch k p m then
  +                match f None with
  +                | None -> t
  +                | Some x -> join k (Tip(k, x)) p t
  +            elif zero k m then
  +                bin p m (alter f k l) r
  +            else
  +                bin p m l (alter f k r)
  +        | Tip(ky, y) -> 
  +            if k = ky then
  +                match f (Some y) with
  +                | Some x -> Tip(ky, x)
  +                | None -> Nil
  +            else
  +                match f None with
  +                | Some x -> join k (Tip(k, x)) ky t
  +                | None -> t
  +        | _ ->
               match f None with
               | Some x -> Tip(k, x)
               | None -> Nil
  
positive.code:     let split k t =
          let rec go k t =
              match t with
              | Bin(p, m, l, r) when nomatch k p m -> if k > p then (t, Nil) else (Nil, t)
              | Bin(p, m, l, r) when zero k m ->
                  let (lt, gt) = go k l
                  (lt, append gt r)
              | Bin(p, m, l, r) ->
                  let (lt, gt) = go k r
                  (append l lt, gt)
              | Tip(ky, _) when k > ky -> (t, Nil)
              | Tip(ky, _) when k < ky -> (Nil, t)
              | Tip(ky, _) -> (Nil, Nil)
              | Nil -> (Nil, Nil)
          match t with
          | Bin(_, m, l, r) when  m < 0 ->
              if k >= 0 // handle negative numbers.
  
negative.code:             | Tip(kx, x) -> f kx x z
              | Bin(_, _, l, r) -> go (go z r) l
          match x with
          | Bin(_, m, l, r) -> 
              if m < 0 then go (go z l) r  // put negative numbers before.
              else go (go z r) l
          | _ -> go z x
      
      member x.ToList() = x.FoldBackWithKey (fun k x xs -> (k, x) :: xs) []
  