for (const [name, node] of rootNode) {
      if (
        !opts.includeNodeModules &&
        isDirectory(node) &&
        name === 'node_modules'
      ) {
        continue;
      }
      const prefixedName = prefix === '' ? name : prefix + path.sep + name;
      if (isDirectory(node)) {
        yield* this._metadataIterator(node, opts, prefixedName);
      } else if (isRegularFile(node) || opts.includeSymlinks) {
        yield {canonicalPath: prefixedName, metadata: node, baseName: name};
      }
    }
Given a start path (which need not exist), a subpath and type, and
optionally a 'breakOnSegment', performs the following:

X = mixedStartPath
do
  if basename(X) === opts.breakOnSegment
    return null
  if X + subpath exists and has type opts.subpathType
    return {
      absolutePath: realpath(X + subpath)
      containerRelativePath: relative(mixedStartPath, X)
    }
  X = dirname(X)
while X !== dirname(X)

If opts.invalidatedBy is given, collects all absolute, real paths that if
added or removed may invalidate this result.

Useful for finding the closest package scope (subpath: package.json,
type f, breakOnSegment: node_modules) or closest potential package root
(subpath: node_modules/pkg, type: d) in Node.js resolution.