anchor.diff:      end.
   
   %% @doc Processes compare results from merkle_check_node/22 on the initiator.
  +%       Note that only hash matches(!) count for HashCmpI_OUT and HashCmpL_OUT
  +%       since mismatches are always correct (the items must differ!)
  +%       -> don't count mismatches since these values ebter the failure probability
   -spec merkle_cmp_result(
           bitstring(), RestTree::NodeList,
           SigSizeI::signature_size(), SigSizeL::signature_size(),
  
positive.code:                     SyncAccRcv1 =
                          [{MaxItemsCount, merkle_tree:get_bucket(Node)} | SyncAccRcv],
                      SyncAccRcvLeafCount1 = SyncAccRcvLeafCount + 1,
                      OtherSyncAccDRLCount1 = OtherSyncAccDRLCount,
                      HashCmpL_OUT = HashCmpL_IN + 1;
                  true -> % stop_empty_leaf2
                      % -> resolved directly at the other node, i.e. without a trivial sub process
                      SyncAccRcv1 = SyncAccRcv,
                      SyncAccRcvLeafCount1 = SyncAccRcvLeafCount,
                      OtherSyncAccDRLCount1 = OtherSyncAccDRLCount + 1,
                      HashCmpL_OUT = HashCmpL_IN
              end;
          false -> % stop_leaf
              {MyKVItems, LeafCount} = merkle_tree:get_items([Node]),
              SyncAccRcv1 =
                  [{MyMaxItemsCount, MyKVItems} | SyncAccRcv],
              SyncAccRcvLeafCount1 = SyncAccRcvLeafCount + LeafCount,
              OtherSyncAccDRLCount1 = OtherSyncAccDRLCount,
              HashCmpL_OUT = HashCmpL_IN
      end,
      merkle_cmp_result(TR, TN, SigSizeI, SigSizeL,
                        MyMaxItemsCount, OtherMaxItemsCount, SyncIn, Params, Stats,
                        RestTreeAcc, SyncAccSend, SyncAccRcv1, SyncAccRcvLeafCount1,
                        MySyncAccDRK, MySyncAccDRLCount, OtherSyncAccDRLCount1,
                        AccCmp + 1, AccSkip,
                        NextLvlNodesActIN, HashCmpI_IN, HashCmpL_OUT).
  
  %% @doc Helper for adding a leaf node's KV-List to a compressed binary
  %%      during merkle sync.
  
negative.code:            % both inner nodes
             Childs = merkle_tree:get_childs(Node),
             NextLvlNodesActOUT = NextLvlNodesActIN + Params#merkle_params.branch_factor,
             merkle_check_node(TK, TN, SigSizeI, SigSizeL,
                               MyMaxItemsCount, OtherMaxItemsCount, Params, Stats,
                               <<FlagsAcc/bitstring, ?recon_fail_cont_inner:2>>, lists:reverse(Childs, RestTreeAcc),
                               SyncAccSend, SyncAccRcv, SyncAccRcvLeafCount,
                               MySyncAccDRK, MySyncAccDRLCount, OtherSyncAccDRLCount,
                               SyncIN, AccCmp + 1, AccSkip,
                               NextLvlNodesActOUT, HashCmpI_IN, HashCmpL_IN);
         (not IsLeafNode) andalso NonEmptyLeafHash ->
             % inner node here, non-empty leaf there
             % no need to compare hashes - this is an exact process based on the tags
  