Skip to content

Instantly share code, notes, and snippets.

@njofce
Created March 22, 2020 21:26
Show Gist options
  • Select an option

  • Save njofce/a1b8b937f57e0a199279ea41da0169ed to your computer and use it in GitHub Desktop.

Select an option

Save njofce/a1b8b937f57e0a199279ea41da0169ed to your computer and use it in GitHub Desktop.
getFlatTree(): TreeNode[] {
return this.flatTreeRecursive(this._root);
}
private flatTreeRecursive(root: TreeNode): TreeNode[] {
let res = [];
for (let c of root.children) {
res.push(c);
res = res.concat(this.flatTreeRecursive(c));
}
return res;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment