//深度优先遍历的递归写法 function DFTraversal(node) { var nodes = []; if (node != null) { nodes.push(node); var children = node.children; for (var i = 0; i < children.length; i++){ deepTraversal(children[i]); } } return nodes; } //深度优先遍历的非递归写法 function DFT(node…