anchor.diff:      let rec find k m =
           let notFound() = failwith <| sprintf "intmap.find: key %d is not an element of the map" k
           match m with
  -        | Bin(p, m, l, r) when nomatch k p m -> notFound()
  -        | Bin(p, m, l, r) when zero k m -> find k l
  -        | Bin(p, m, l, r) -> find k r
  +        | Bin(p, m, l, r) -> 
  +            if nomatch k p m then notFound()
  +            else if zero k m then find k l
  +            else find k r
           | Tip(kx, x) when k = kx -> x
  -        | Tip(kx, x) -> notFound()
  -        | Nil -> notFound()
  +        | _ -> notFound()
   
       ///O(min(n,W)). The expression (findWithDefault def k map) returns the value at key k or returns def when the key is not an element of the map.  Credit: Haskell.org
       let rec findWithDefault def k =
           function
  -        | Bin(p, m, l, r) when nomatch k p m -> def
  -        | Bin(p, m, l, r) when zero k m -> findWithDefault def k l
  -        | Bin(p, m, l, r) -> findWithDefault def k r
  +        | Bin(p, m, l, r) -> 
  +            if nomatch k p m then def
  +            elif zero k m then findWithDefault def k l
  +            else findWithDefault def k r
           | Tip(kx, x) when k = kx -> x
  -        | Tip(kx, x) -> def
  -        | Nil -> def
  +        | _ -> def
   
       let rec private unsafeFindMax =
           function
  
positive.code:     let rec filterWithKey predicate =
          function
          | Bin(p, m, l, r) -> bin p m (filterWithKey predicate l) (filterWithKey predicate r)
          | Tip(k, x) when predicate k x -> Tip(k, x)
          | Tip _ -> Nil
          | Nil -> Nil
  
      ///O(n). Filter all values that satisfy some predicate. Credit: Haskell.org
      let filter p m = filterWithKey (fun _ x -> p x) m
  
      ///O(n). partition the map according to some predicate. The first map contains all elements that satisfy the predicate, the second all elements that fail the predicate. See also split. Credit: Haskell.org
      let rec partitionWithKey predicate t =
          match t with
          | Bin(p, m, l, r)  ->
              let (l1, l2) = partitionWithKey predicate l
              let (r1, r2) = partitionWithKey predicate r
              (bin p m l1 r1, bin p m l2 r2)
          | Tip(k, x) when predicate k x -> (t, Nil)
          | Tip _-> (Nil, t)
          | Nil -> (Nil, Nil)
  
      ///O(n). partition the map according to some predicate. The first map contains all elements that satisfy the predicate, the second all elements that fail the predicate. See also split. Credit: Haskell.org
      let partition p m = partitionWithKey (fun _ x -> p x) m
  
negative.code:             if t1 == t2 then
                  Nil
              else
                  match t1 with
                  | Bin(p1, m1, l1, r1) ->
                      match t2 with
                      | Bin(p2, m2, l2, r2) ->
                          if shorter m1 m2 then merge1 p1 m1 t1 l1 r1 p2 m2 t2
                          elif shorter m2 m1 then merge2 p1 m1 t1 p2 m2 t2 l2 r2
                          elif p1 = p2 then bin p1 m1 (go l1 l2) (go r1 r2)
                          else maybe_join p1 (del t1) p2 (add t2)
                      | Tip (k2', _) ->
                          let rec merge t2 k2 t1 =
                              match t1 with
                              | Bin(p1, m1, l1, r1) ->
                                  if nomatch k2 p1 m1 then maybe_join p1 (del t1) k2 (add t2)
                                  elif zero k2 m1 then bin p1 m1 (merge t2 k2 l1) (del r1)
                                  else bin p1 m1 (del l1) (merge t2 k2 r1)
                              | Tip(k1, _) ->
                                  if k1 = k2 then ifChanged t1 t2
                                  else maybe_join k1 (del t1) k2 (add t2)
                              | _ -> add t2
                          merge t2 k2' t1
                      | _ -> del t1
                  | Tip(k1', _) ->
                      let rec merge t1 k1 t2 =
                          match t2 with
                          | Bin(p2, m2, l2, r2) ->
                              if nomatch k1 p2 m2 then maybe_join k1 (del t1) p2 (add t2)
                              elif zero k1 m2 then bin p2 m2 (merge t1 k1 l2) (add r2)
                              else bin p2 m2 (add l2) (merge t1 k1 r2)
                          | Tip(k2, _) ->
                              if k1 = k2 then ifChanged t1 t2
                              else maybe_join k1 (del t1) k2 (add t2)
                          | _ -> del t1
                      merge t1 k1' t2
                  | _ -> add t2
          go
  
      
  