findRootTypeKey = type => {
  // @ts-ignore _y must be defined, otherwise unexpected case
  for (const [key, value] of type.doc.share.entries()) {
    if (value === type) {
      return key;
    }
  }

  throw error.unexpectedCase();
}
The top types are mapped from y.share.get(keyname) => type.
`type` does not store any information about the `keyname`.
This function finds the correct `keyname` for `type` and throws otherwise.

@param {AbstractType<any>} type
@return {string}

@private
@function