code: private function removeHideIfEmptyGroups(&$log)
      {
          $groupStack = array();
          $groupStackCount = 0;
          $removed = false;
          for ($i = 0, $count = \count($log); $i < $count; $i++) {
              $method = $log[$i][0];
              if (\in_array($method, array('group', 'groupCollapsed'))) {
                  $entry = $log[$i];
                  $groupStack[] = array(
                      'i' => $i,
                      'meta' => !empty($entry[2]) ? $entry[2] : array(),
                      'hasEntries' => false,
                  );
                  $groupStackCount ++;
              } elseif ($method == 'groupEnd') {
                  $group = \end($groupStack);
                  if (!$group['hasEntries'] && !empty($group['meta']['hideIfEmpty'])) {
                      // make it go away
                      unset($log[$group['i']]);
                      unset($log[$i]);
                      $removed = true;
                  }
                  \array_pop($groupStack);
                  $groupStackCount--;
              } elseif ($groupStack) {
                  $groupStack[$groupStackCount - 1]['hasEntries'] = true;
              }
          }
          if ($removed) {
              $log = \array_values($log);
          }
      }
docs: Remove empty groups with 'hideIfEmpty' meta value
  
  @param array $log log or summary
  
  @return void