function toIdOrMemberExpression(ids) {
  let index = -1
  /** @type {Identifier | Literal | MemberExpression | undefined} */
  let object

  while (++index < ids.length) {
    const name = ids[index]
    /** @type {Identifier | Literal} */
    const id =
      typeof name === 'string' && isIdentifierName(name)
        ? {type: 'Identifier', name}
        : {type: 'Literal', value: name}
    object = object
      ? {
          type: 'MemberExpression',
          object,
          property: id,
          computed: id.type === 'Literal',
          optional: false
        }
      : id
  }

  assert(object, 'expected non-empty `ids` to be passed')
  assert(object.type !== 'Literal', 'expected identifier as left-most value')
  return object
}
@param {ReadonlyArray<number | string>} ids
  Identifiers (example: `['list', 0]).
@returns {Identifier | MemberExpression}
  Identifier or member expression.