function simplifyTree(root: Node): Node {
let newChildren = [] as Array<Node>; for (const child of root.children) { const simplifiedChild = simplifyGraph(child); if (shouldContract(simplifiedChild)) { for (const grandChild of simplifiedChild.children) { newChildren.push(grandChild); } } else { newChildren.push(simplifiedChild); } } root.children = newChildren; return root; }
function simplifyTree(root: Node): Node {