function processOnePackageInLogicalTree(
  preferredPackageLogicalPathMap,
  resolve
) {
  const {
    packageDir,
    logicalPath = [],
    includeDevDeps = false,
    visited = new Set(),
  } = /** @type {WalkDepTreeOpts} */ (currentLevelTodos.pop())
  const depsToWalk = getDependencies(packageDir, includeDevDeps)

  // deps are already sorted by preference for paths
  for (const depName of depsToWalk) {
    let depPackageJsonPath = wrappedResolveSync(resolve, depName, packageDir)
    // ignore unresolved deps
    if (!depPackageJsonPath) {
      continue
    }
    const childPackageDir = path.dirname(depPackageJsonPath)
    // avoid cycles, but still visit the same package
    // on disk multiple times through different logical paths
    if (visited.has(childPackageDir)) {
      continue
    }
    const childVisited = new Set([...visited, childPackageDir])
    const childLogicalPath = [...logicalPath, depName]

    // compare this path and current best path
    const theCurrentBest = preferredPackageLogicalPathMap.get(childPackageDir)
    if (comparePackageLogicalPaths(childLogicalPath, theCurrentBest) < 0) {
      // debug: log extraneous path traversals
      // if (theCurrentBest !== undefined) {
      //   console.log(`extraneous "${childPackageDir}"\n  current "${theCurrentBest}"\n  preferd "${childLogicalPath}"`)
      // }
      // set as the new best so far
      preferredPackageLogicalPathMap.set(childPackageDir, childLogicalPath)
      // continue walking children, adding them to the end of the queue
      nextLevelTodos.push({
        packageDir: childPackageDir,
        logicalPath: childLogicalPath,
        includeDevDeps: false,
        visited: childVisited,
      })
    } else {
      // debug: log skipped path traversals
      // console.log(`skipping "${childPackageDir}"\n  preferred "${theCurrentBest}"\n  current "${childLogicalPath}"`)
      // abort this walk, can't do better
      continue
    }
  }
}
@param {Map<string, string[]>} preferredPackageLogicalPathMap
@param {Resolver} resolve