code: protected function mergeItemsResults(Model\SaleItemInterface $item, Amount $result): void
      {
          // At this points items result are calculated and set.
          foreach ($item->getChildren() as $child) {
              if ($child->isPrivate()) {
                  continue;
              }
  
              // Skip compound with only public children
              if (!($child->isCompound() && !$child->hasPrivateChildren())) {
                  $result->merge($child->getResult());
              }
  
              if ($child->hasChildren()) {
                  $this->mergeItemsResults($child, $result);
              }
          }
      }
docs: Merges the public children results recursively into the given result.
  
  @param Model\SaleItemInterface $item
  @param Amount                  $result