code: function getPath(pathType = 'array', _path) {
    return {
      _path: _path || (pathType === 'array' ? [] : ''),
      set(parent, key) {
        let nextPath;
        switch (pathType) {
          case 'array':
            nextPath = this._path.concat([key]);
            break;
  
          case 'nestedProperty':
            if (this._path.length === 0) {
              nextPath = key;
            } else if (Array.isArray(parent)) {
              nextPath = this._path + `[${key}]`;
            } else {
              nextPath = this._path + '.' + key;
            }
            break;
  
          default:
            throw new Error('unrecognized pathType ' + pathType);
        }
  
        return getPath(pathType, nextPath);
      },
  
      get(parent, key) {
        // in array mode we do not return the leaf node key.
        if (pathType === 'array') {
          return this._path;
        }
  
        // in nestedProperty mode we return full path including final key
        return this.set(parent, key)._path;
      },
    };
  }
docs: /*
  Helper utility for path accumulation in _walkObject. Supports array
  path accumulation and also Plotly.js nestedProperty style.