function inventory$Ref ($refParent, $refKey, path, pathFromRoot, indirections, inventory, $refs, options) {
var $ref = $refKey === null ? $refParent : $refParent[$refKey];
var $refPath = url.resolve(path, $ref.$ref);
var pointer = $refs._resolve($refPath, options);
var depth = Pointer.parse(pathFromRoot).length;
var file = url.stripHash(pointer.path);
var hash = url.getHash(pointer.path);
var external = file !== $refs._root$Ref.path;
var extended = $Ref.isExtended$Ref($ref);
indirections += pointer.indirections;

var existingEntry = findInInventory(inventory, $refParent, $refKey);
if (existingEntry) {
  // This $Ref has already been inventoried, so we don't need to process it again
  if (depth < existingEntry.depth || indirections < existingEntry.indirections) {
    removeFromInventory(inventory, existingEntry);
  }
  else {
    return;
  }
}

inventory.push({
  $ref: $ref,                   // The JSON Reference (e.g. {$ref: string})
  parent: $refParent,           // The object that contains this $ref pointer
  key: $refKey,                 // The key in `parent` that is the $ref pointer
  pathFromRoot: pathFromRoot,   // The path to the $ref pointer, from the JSON Schema root
  depth: depth,                 // How far from the JSON Schema root is this $ref pointer?
  file: file,                   // The file that the $ref pointer resolves to
  hash: hash,                   // The hash within `file` that the $ref pointer resolves to
  value: pointer.value,         // The resolved value of the $ref pointer
  circular: pointer.circular,   // Is this $ref pointer DIRECTLY circular? (i.e. it references itself)
  extended: extended,           // Does this $ref extend its resolved value? (i.e. it has extra properties, in addition to "$ref")
  external: external,           // Does this $ref pointer point to a file other than the main JSON Schema file?
  indirections: indirections,   // The number of indirect references that were traversed to resolve the value
});

// Recursively crawl the resolved value
crawl(pointer.value, null, pointer.path, pathFromRoot, indirections + 1, inventory, $refs, options);
}
Inventories the given JSON Reference (i.e. records detailed information about it so we can
optimize all $refs in the schema), and then crawls the resolved value.

@param {object} $refParent - The object that contains a JSON Reference as one of its keys
@param {string} $refKey - The key in `$refParent` that is a JSON Reference
@param {string} path - The full path of the JSON Reference at `$refKey`, possibly with a JSON Pointer in the hash
@param {string} pathFromRoot - The path of the JSON Reference at `$refKey`, from the schema root
@param {object[]} inventory - An array of already-inventoried $ref pointers
@param {$Refs} $refs
@param {$RefParserOptions} options