function deepPruneItemForKeySerialization(item) {
  if (typeof item !== 'object') return item;
  if (item === null) return item;

  if (Array.isArray(item)) {
    return item.map(entry => deepPruneItemForKeySerialization(entry));
  } else {
    const itemAsRecord = /** @type {Record<string, unknown>} */ (item);
    const keys = Object.keys(item);
    const keysToKeep = keys.filter(key => !key.startsWith('_'));
    /** @type {Record<string, any>} */
    const copy = {};
    for (const key of keysToKeep) {
      copy[key] = deepPruneItemForKeySerialization(itemAsRecord[key]);
    }
    return copy;
  }
}
The items passed to this method can be dirtied by other libraries and contain circular structures.
Prune any private-looking properties that start with `_` throughout the entire object.

@see https://github.com/GoogleChrome/lighthouse-ci/issues/666
@param {unknown} item
@return {unknown}