title: BFS in JavaScript using Recursion
body: <p>It is easy to do DFS using recursion:</p>
  
  <pre><code>function dfs(tree, fn, level) {
    fn(tree, level)
    tree.children.forEach(function(child){
      dfs(child, fn, level + 1)
    })
  }
  </code></pre>
  
  <p>However every <a href="https://stackoverflow.com/questions/33703019/breadth-first-traversal-of-a-tree-in-javascript/33704700#33704700">example</a> I have seen of BFS uses a queue and is iterative rather than recursive. Wondering if there is any way to define a recursive BFS algorithm.</p>