anchor.diff:  -spec map_key_to_interval(?RT:key(), intervals:interval()) -> ?RT:key().
   map_key_to_interval(Key, I) ->
       RGrp = [K || K <- lists:sort(?RT:get_replica_keys(Key)), intervals:in(K, I)],
  -    case length(RGrp) of
  -        0 -> erlang:error(e);
  -        1 -> erlang:hd(RGrp);
  -        _ ->
  -            RGrpDis = [{X, ?RT:get_range(Key, X)} || X <- RGrp],
  -            element(1, erlang:hd(lists:keysort(2, RGrpDis)))
  +    case RGrp of
  +        [R] -> R;
  +        [_|_] -> RGrpDis = [case X of
  +                                Key -> {X, 0};
  +                                _ -> {X, min(?RT:get_range(Key, X), ?RT:get_range(X, Key))}
  +                            end || X <- RGrp],
  +                 element(1, erlang:hd(lists:keysort(2, RGrpDis)))
       end.
   
   -spec map_key_to_quadrant(?RT:key(), pos_integer()) -> ?RT:key().
  
positive.code:     LQ = get_key_quadrant(LKey),
      RepFactor = rep_factor(),
      QDiff = (RepFactor - LQ + Q) rem RepFactor,
      intervals:new(LBr,
                    add_quadrants_to_key(LKey, QDiff, RepFactor),
                    add_quadrants_to_key(RKey, QDiff, RepFactor),
                    RBr).
  
  % @doc Gets intersection of two associated intervals as sub interval of A.
  -spec find_intersection(intervals:interval(), intervals:interval()) -> intervals:interval().
  find_intersection(A, B) ->
      lists:foldl(fun(Q, Acc) ->
                          Sec = intervals:intersection(A, mapInterval(B, Q)),
                          case intervals:is_empty(Acc) 
                                   andalso not intervals:is_empty(Sec) of
                              true -> Sec;
                              false -> Acc
                          end
                      end, intervals:empty(), lists:seq(1, rep_factor())).
  
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  
  
negative.code: -export([encodeBlob/2, decodeBlob/1,
           map_key_to_interval/2,
           mapInterval/2, map_key_to_quadrant/2, 
           get_key_quadrant/1, get_interval_quadrant/1,
           find_intersection/2]).
  
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  % debug
  