(node: "Node")
| 627 | """Count total nodes in the tree (for testing/debugging)""" |
| 628 | |
| 629 | def count_nodes(node: "Node") -> int: |
| 630 | if node.is_leaf(): |
| 631 | return 1 |
| 632 | total = 1 |
| 633 | for child in node.children: |
| 634 | total += count_nodes(child) |
| 635 | return total |
| 636 | |
| 637 | return count_nodes(self.root) |
| 638 |