function inspectArrayPatternForDeclarations(node, keyPath) {
  // if it has a RestElement, we cant meaningfully pursue any deeper
  // return the node with the current path
  const expansionForbidden = node.elements.some(
    (el) => el?.type === 'RestElement'
  )
  if (expansionForbidden) {
    return [{ node, keyPath }]
  }
  /** @type {Declaration[]} */
  let results = []
  // expand each property into a path, recursively
  node.elements.forEach((child, propName) => {
    if (child) {
      results = results.concat(
        inspectPatternElementForDeclarations(child, [
          ...keyPath,
          String(propName),
        ])
      )
    }
  })
  return results
}
@param {import('@babel/types').ArrayPattern} node
@param {string[]} keyPath
@returns {Declaration[]}