anchor.diff:  merkle_resolve_compare_inner_leaf(P1EOneLeaf, MyMaxItemsCount, BucketSizeBits,
                                     MyBuckets, NLeafNAcc, Hashes, ToSend, ToReq,
                                     ToResolve, ResolveNonEmptyAcc) ->
  -    {NHashes, OBucketHashes, OBucketTree, SigSize, VSize} =
  +    {NHashes, OBucketTree, SigSize, VSize} =
           merkle_resolve_retrieve_leaf_hashes(Hashes, P1EOneLeaf, MyMaxItemsCount, BucketSizeBits),
  -    {ToSend1, ToReq1, OBucketTree1} =
  +    OrigDBChunkLen = gb_trees:size(OBucketTree),
  +    {ToSend1, ToReqIdx1, OBucketTree1} =
           get_full_diff(MyBuckets, OBucketTree, ToSend, [], SigSize, VSize),
  -    ReqTree = lists:foldl(fun(KeyBin, Acc) ->
  -                                  gb_trees:enter(KeyBin, 0, Acc)
  -                          end, OBucketTree1, ToReq1),
  -    ToResolve1 = [compress_k_list(ReqTree, OBucketHashes, SigSize, VSize,
  -                                  0, [], 0, 0) | ToResolve],
  -    ResolveNonEmptyAcc1 =
  -        ?IIF(gb_trees:size(ReqTree) =/= 0, true, ResolveNonEmptyAcc),
  +    ReqIdx = lists:usort([Idx || {_Version, Idx} <- gb_trees:values(OBucketTree1)] ++ ToReqIdx1),
  +    ToResolve1 = [compress_idx_list(ReqIdx, OrigDBChunkLen, [], 0, 0) | ToResolve],
  +    ResolveNonEmptyAcc1 = ?IIF(ReqIdx =/= [], true, ResolveNonEmptyAcc),
       {NHashes, ToSend1, ToReq, ToResolve1, ResolveNonEmptyAcc1, NLeafNAcc}.
   
   %% @doc Helper for the final resolve step during merkle sync.
  
positive.code: %%      and the entry in MyEntries has a newer version than the one in the tree
  %%      and returns them as FBItems. ReqItems contains items in the tree but
  %%      where the version in MyEntries is older than the one in the tree.
  -spec get_part_diff(MyEntries::db_chunk_kv(), MyIOtherKvTree::kv_tree(),
                      AccFBItems::[?RT:key()], AccReqItems::[bitstring()],
                      SigSize::signature_size(), VSize::signature_size())
          -> {FBItems::[?RT:key()], ReqItems::[bitstring()], MyIOtherKvTree::kv_tree()}.
  get_part_diff(MyEntries, MyIOtKvTree, FBItems, ReqItems, SigSize, VSize) ->
      get_part_diff_(MyEntries, MyIOtKvTree, FBItems, ReqItems, SigSize,
                     util:pow(2, VSize)).
  
  %% @doc Helper for get_part_diff/6.
  -spec get_part_diff_(MyEntries::db_chunk_kv(), MyIOtherKvTree::kv_tree(),
                       AccFBItems::[?RT:key()], AccReqItems::[bitstring()],
                       SigSize::signature_size(), VMod::pos_integer())
          -> {FBItems::[?RT:key()], ReqItems::[bitstring()], MyIOtherKvTree::kv_tree()}.
  get_part_diff_([], MyIOtKvTree, FBItems, ReqItems, _SigSize, _VMod) ->
      {FBItems, ReqItems, MyIOtKvTree};
  get_part_diff_([{Key, Version} | Rest], MyIOtKvTree, FBItems, ReqItems, SigSize, VMod) ->
      {KeyBin, VersionShort} = compress_kv_pair(Key, Version, SigSize, VMod),
      case gb_trees:lookup(KeyBin, MyIOtKvTree) of
          none ->
              get_part_diff_(Rest, MyIOtKvTree, FBItems, ReqItems,
                             SigSize, VMod);
          {value, OtherVersionShort} ->
              MyIOtKvTree2 = gb_trees:delete(KeyBin, MyIOtKvTree),
              if VersionShort > OtherVersionShort ->
                     get_part_diff_(Rest, MyIOtKvTree2, [Key | FBItems], ReqItems,
                                    SigSize, VMod);
                 VersionShort =:= OtherVersionShort ->
                     get_part_diff_(Rest, MyIOtKvTree2, FBItems, ReqItems,
                                    SigSize, VMod);
                 true ->
                     get_part_diff_(Rest, MyIOtKvTree2, FBItems, [KeyBin | ReqItems],
                                    SigSize, VMod)
              end
      end.
  
negative.code:     NewStats1 = rr_recon_stats:inc([{resolve_started, 1}], Stats),
  
      % let the initiator's rr_recon process identify the remaining keys
      ReqIdx = lists:usort([Idx || {_Version, Idx} <- gb_trees:values(DBChunkTree1)] ++ ToReqIdx1),
      ToReq2 = compress_idx_list(ReqIdx, OrigDBChunkLen, [], 0, 0),
      ?TRACE("resolve_req ~s Session=~p ; ToReq=~p (~p bits)",
             [_RMethod, SID, length(ToReq2), erlang:bit_size(ToReq2)]),
      comm:send(DestReconPid, {resolve_req, ToReq2}),
      if ReqIdx =/= [] ->
             rr_recon_stats:inc([{resolve_started, 1}], NewStats1);
         true -> NewStats1
      end.
  