function getParents(nodePath) {
  /** @type {import('@babel/types').Node[]} */
  const parents = []
  let target = nodePath
  while (target) {
    parents.push(target.node)
    target = /** @type {import('@babel/traverse').NodePath<any>} */ (
      target.parentPath
    )
  }
  parents.reverse()
  return parents
}
Returns an array of a `NodePath`'s parent nodes (to the root)

@param {import('@babel/traverse').NodePath<any> | null} nodePath
@returns {import('@babel/types').Node[]}