coerceToOptions(json) {
    /** @type {LH.Treemap.Options['lhr']|null} */
    let lhr = null;
    if (json && typeof json === 'object') {
      for (const maybeLhr of [json, json.lhr, json.lighthouseResult]) {
        if (maybeLhr?.audits && typeof maybeLhr.audits === 'object') {
          lhr = maybeLhr;
          break;
        }
      }
    }

    if (!lhr) {
      throw new Error('provided json is not a Lighthouse result');
    }

    if (!lhr.audits['script-treemap-data']) {
      throw new Error('provided Lighthouse result is missing audit: `script-treemap-data`');
    }

    let initialView;
    if (json && typeof json === 'object' && typeof json.initialView === 'string') {
      initialView = json.initialView;
    }

    return {lhr, initialView};
  }
Coerce json into LH.Treemap.Options
Accepts if json is an lhr, or {lhr: ...} or {lighthouseResult: ...}
Throws error if json does not match expectations.
@param {any} json
@return {LH.Treemap.Options}