function walkDependencyTreeForBestLogicalPaths({
  packageDir,
  logicalPath = [],
  includeDevDeps = false,
  visited = new Set(),
  resolve = performantResolve,
}) {
  /** @type {Map<string, string[]>} */
  const preferredPackageLogicalPathMap = new Map()
  // add the entry package as the first work unit
  currentLevelTodos = [
    { packageDir, logicalPath, includeDevDeps, visited, resolve },
  ]
  nextLevelTodos = []
  // drain work queue until empty, avoid going depth-first by prioritizing the current depth level
  do {
    processOnePackageInLogicalTree(preferredPackageLogicalPathMap, resolve)
    if (currentLevelTodos.length === 0) {
      currentLevelTodos = nextLevelTodos
      nextLevelTodos = []
    }
  } while (currentLevelTodos.length > 0)

  for (const [
    packageDir,
    logicalPath,
  ] of preferredPackageLogicalPathMap.entries()) {
    if (isSymlink(packageDir)) {
      const realPath = realpathSync(packageDir)
      preferredPackageLogicalPathMap.set(realPath, logicalPath)
    }
  }
  return preferredPackageLogicalPathMap
}
@param {WalkDepTreeOpts} options
@returns {Map<string, string[]>}