<commit_before>'use strict';

var circular = exports;


// @param {Object} current The relative node 
// @param {Object} target The node to be tested
// @returns
// - null if no circle
// - `Array` if has a circle
circular.trace = function (current, target) {
  var trace = [current];

  if (current === target) {
    return null;
  }

  return circular.lookBack(current, target, trace);
};


circular.lookBack = function (relative, target, trace) {
  trace.push(target);

  if (relative === target) {
    return trace;
  }


  // if meets the end, just pop.
  if (!target.dependents || target.dependents.length === 0) {
    trace.pop();
    return null;
  }

  var found = target.dependents.some(function (new_target) {
    return circular.lookBack(relative, new_target, trace);
  });

  if (!found) {
    // If not found, recursively pop()
    trace.pop();
    return null;
  }
<commit_msg>#6: renames variables, adds comments<commit_after>'use strict';

var circular = exports;


// @param {Object} from The from node, the spring generations
// @param {Object} to The node to be tested, the ancestors
// @returns
// - null if no circle
// - `Array` if has a circle
circular.trace = function (from, to) {
  var trace = [from];

  if (from === to) {
    return null;
  }

  return circular.lookBack(from, to, trace);
};


circular.lookBack = function (from, to, trace) {
  trace.push(to);

  if (from === to) {
    return trace;
  }


  // if meets the end, just pop.
  if (!to.dependents || to.dependents.length === 0) {
    trace.pop();
    return null;
  }

  var found = to.dependents.some(function (new_to) {
    return circular.lookBack(from, new_to, trace);
  });

  if (!found) {
    // If not found, recursively pop()
    trace.pop();
    return null;
  }

{'fraction_non_alphanumeric': 0.14665911664779163, 'fraction_numerical': 0.0016987542468856172, 'mean_word_length': 2.9354120267260577, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '456339', 'n_tokens_mistral': 587, 'n_tokens_neox': 566, 'n_words': 183}