index.js
function treeDFS(tree, callback) {
  for (let it of tree.slice()) {
    callback(it, tree);
    if (typeof it === 'object') {
      treeDFS(it.children, callback);
    }
  }
}
function treeDFS(tree, callback) {
  for (let it of tree.slice()) {
    callback(it, tree);
    if (typeof it === 'object') {
      treeDFS(it.children, callback);
    }
  }
}
function treeDFS ( tree , callback ) { for ( let it of tree . slice ( ) ) { callback ( it , tree ) ; if ( typeof it === 'object' ) { treeDFS ( it . children , callback ) ; } } }
traverse tree with dfs
traverse tree with dfs