* Update depth and height of this subtree.
(depth: number)
| 138 | * Update depth and height of this subtree. |
| 139 | */ |
| 140 | updateDepthAndHeight(depth: number) { |
| 141 | let height = 0; |
| 142 | this.depth = depth; |
| 143 | for (let i = 0; i < this.children.length; i++) { |
| 144 | const child = this.children[i]; |
| 145 | child.updateDepthAndHeight(depth + 1); |
| 146 | if (child.height > height) { |
| 147 | height = child.height; |
| 148 | } |
| 149 | } |
| 150 | this.height = height + 1; |
| 151 | } |
| 152 | |
| 153 | getNodeById(id: string): TreeNode { |
| 154 | if (this.getId() === id) { |