function inspectObjectPatternForDeclarations(node, keyPath) {
  // if it has computed props or a RestElement, we cant meaningfully pursue any deeper
  // return the node with the current path
  const expansionForbidden = node.properties.some(
    (prop) =>
      /** @type {import('@babel/types').ObjectProperty} */ (prop).computed ||
      prop.type === 'RestElement'
  )
  if (expansionForbidden) {
    return [{ node, keyPath }]
  }
  /** @type {Declaration[]} */
  let results = []
  // expand each property into a path, recursively
  node.properties.forEach((prop) => {
    // @ts-expect-error - could be a RestElement
    if ('name' in prop.key) {
      // @ts-expect-error - could be a RestElement
      const propName = prop.key.name
      // @ts-expect-error - could be a RestElement
      const child = prop.value
      results = results.concat(
        inspectPatternElementForDeclarations(child, [...keyPath, propName])
      )
    }
  })
  return results
}
@param {import('@babel/types').ObjectPattern} node
@param {string[]} keyPath
@returns {Declaration[]}