anchor.diff:      min_max(util:ceil(util:log2(N / P1E)), 1, MaxSize).
   
   %% @doc Calculates from a total P1E the (next) P1E to use for signature and
  -%%      sub-tree reconciliations.
  --spec merkle_next_p1e(BranchFactor::pos_integer(), P1ETotal::float()) -> P1E::float().
  +%%      sub-tree/trivial reconciliations.
  +-spec merkle_next_p1e(BranchFactor::pos_integer(), P1ETotal::float())
  +    -> {P1E_I::float(), P1E_L::float()}.
   merkle_next_p1e(BranchFactor, P1ETotal) ->
  -    % current node can make a mistake or any of its BranchFactor children
  -    % => current node's probability of 0 errors = P0E(child)^(BranchFactor+1)
  +    % mistakes caused by:
  +    % inner node: current node or any of its BranchFactor children (B=BranchFactor+1)
  +    % leaf node: current node or the following trivial reconciliation (B=2)
  +    % => current node's probability of 0 errors = P0E(child)^B
       % however, we cannot use P0E=(1-P1E) since it is near 1 and its floating
       % point representation is sub-optimal!
  -    % => use Taylor expansion of P1E_next = 1 - (1-P1E)^(1/BranchFactor)
  -    BF = BranchFactor + 1,
  -    _P1E = P1ETotal / BF +
  -              (BF - 1) * P1ETotal * P1ETotal / (2 * BF * BF). % +O[p^3]
  +    % => use Taylor expansion of P1E_next = 1 - (1-P1E)^(1/B)
  +    BI = BranchFactor + 1,
  +    P1E_I = P1ETotal / BI +
  +              (BI - 1) * P1ETotal * P1ETotal / (2 * BI * BI), % +O[p^3]
  +    P1E_L = P1ETotal / 2 + P1ETotal * P1ETotal / 8, % +O[p^3]
  +    {P1E_I, P1E_L}.
   
   %% @doc Calculates the new signature sizes based on the next P1E as in
   %%      merkle_next_p1e/2
  
positive.code:         Params::#merkle_params{}, P1ETotal::float(),
          MyMaxLeafCount::non_neg_integer(), MyMaxItemsCount::non_neg_integer(),
          OtherMaxLeafCount::non_neg_integer(), OtherMaxItemsCount::non_neg_integer())
      -> {P1E::float(), NextSigSizeI::signature_size(), NextSigSizeL::signature_size()}.
  merkle_next_signature_sizes(
    #merkle_params{bucket_size = BucketSize, branch_factor = BranchFactor}, P1ETotal,
    MyMaxLeafCount, MyMaxItemsCount, OtherMaxLeafCount, OtherMaxItemsCount) ->
      P1E = merkle_next_p1e(BranchFactor, P1ETotal),
  
      % note: we need to use the same P1E for this level's signature
      %       comparison as a children's tree has in total!
  
negative.code:             MyItemCount = merkle_tree:get_item_count(MySyncStruct),
  
              OtherItemsCount = OtherLeafCount * BucketSize - LeafItemsCountDiff,
              {P1E_I, P1E_L, NextSigSizeI, NextSigSizeL} =
                  merkle_next_signature_sizes(Params, P1ETotal, MyLeafCount, MyItemCount,
                                              OtherLeafCount, OtherItemsCount),
  
  