code: function _getGraphDetails(tree) {
    var maxDepth = 0,
        leafCount = 0,
  
        links = _getLinks(tree);
  
    tree.ifForEach('children', function (child) {
      var details = _getGraphDetails(child);
      maxDepth = Math.max(maxDepth, details.maxDepth);
      leafCount += details.leafCount;
  
      links.push.apply(links, details.links);
    });
  
    if(!tree.get('children')) {
      leafCount++;
    }
  
    return {
      tree: tree,
      links: links,
      maxDepth: maxDepth + 1,
      leafCount: leafCount
    };
  }
docs: Step 4: Recursive
  Create a graph based on the given tree structure and edges in _data object.
  @param tree {DataNode}
  @param details {Object} Object with values tree, links, maxDepth & maxHeight