index.js
function depthFirst(node, parent) {
  var results = [];
  if (node && (typeof node === 'object')) {

    // valid node so push it to the list and set new parent
    //  don't overwrite parent if one was not given
    if ('type' in node) {
      if (parent !== undefined) {
        node.parent = parent;
      }
      parent = node;
      results.push(node);
    }

    // recurse object members using nested function call
    for (var key in node) {
      if (WHITE_LIST.test(key)) {
        var value = node[key];
        if (value && (typeof value === 'object')) {
          results.push.apply(results, depthFirst(value, parent));
        }
      }
    }
  }
  return results;
}
function depthFirst(node, parent) {
  var results = [];
  if (node && (typeof node === 'object')) {

    // valid node so push it to the list and set new parent
    //  don't overwrite parent if one was not given
    if ('type' in node) {
      if (parent !== undefined) {
        node.parent = parent;
      }
      parent = node;
      results.push(node);
    }

    // recurse object members using nested function call
    for (var key in node) {
      if (WHITE_LIST.test(key)) {
        var value = node[key];
        if (value && (typeof value === 'object')) {
          results.push.apply(results, depthFirst(value, parent));
        }
      }
    }
  }
  return results;
}
function depthFirst ( node , parent ) { var results = [ ] ; if ( node && ( typeof node === 'object' ) ) { // valid node so push it to the list and set new parent //  don't overwrite parent if one was not given if ( 'type' in node ) { if ( parent !== undefined ) { node . parent = parent ; } parent = node ; results . push ( node ) ; } // recurse object members using nested function call for ( var key in node ) { if ( WHITE_LIST . test ( key ) ) { var value = node [ key ] ; if ( value && ( typeof value === 'object' ) ) { results . push . apply ( results , depthFirst ( value , parent ) ) ; } } } } return results ; }
List the given node and all children, depth first.
@param {object} node An esprima node
@param {object|undefined} [parent] The parent of the given node, where known
@returns {Array} A list of nodes
List the given node and all children depth first .