anchor.diff:              TargetCount >= SourceCount ->
                   % Executing this move would create a local imbalance in the DB
                   true;
  -            Total >= TargetLevel ->
  -                % The candidate has already achieved the target level
  +            TotalTarget > TargetLevel ->
  +                % The candidate has already exceeded the target level
  +                true;
  +            (TotalSource - TotalTarget) < 2 ->
  +                % Donating here is wasted work
                   true;
               true ->
                   false
  
positive.code:     InZone = filter_map_by_zone(shards_by_node(Shards, Nodes), Zone),
      SortedByCount = lists:sort(smallest_first(Moves), InZone),
      SourceCount = get_shard_count(Node, SortedByCount),
      Fun = fun({CandidateNode, OwnShards}) ->
          HasRange = lists:keymember(Shard#shard.range, #shard.range, OwnShards),
          TargetCount = get_shard_count(CandidateNode, SortedByCount),
          NodeKey = couch_util:to_binary(CandidateNode),
          Total = couch_util:get_value(NodeKey, shard_count_by_node(Moves)),
          if
              CandidateNode =:= Node ->
                  % Can't move a shard to ourselves
  
negative.code:     fun(A, B) -> sort_by_count(A, B, Global) =< 0 end.
  
  sort_by_count({NodeA, SA}, {NodeB, SB}, Global) when length(SA) =:= length(SB) ->
      CountA = get_global_shard_count(NodeA, Global),
      CountB = get_global_shard_count(NodeB, Global),
      cmp(CountA, CountB);
  sort_by_count({_, A}, {_, B}, _) ->
      cmp(length(A), length(B)).
  