| 6 | |
| 7 | @dataclass |
| 8 | class Node: |
| 9 | data: int |
| 10 | left: Node | None = None |
| 11 | right: Node | None = None |
| 12 | |
| 13 | def __iter__(self) -> Iterator[int]: |
| 14 | if self.left: |
| 15 | yield from self.left |
| 16 | yield self.data |
| 17 | if self.right: |
| 18 | yield from self.right |
| 19 | |
| 20 | def __len__(self) -> int: |
| 21 | return sum(1 for _ in self) |
| 22 | |
| 23 | def is_full(self) -> bool: |
| 24 | if not self or (not self.left and not self.right): |
| 25 | return True |
| 26 | if self.left and self.right: |
| 27 | return self.left.is_full() and self.right.is_full() |
| 28 | return False |
| 29 | |
| 30 | |
| 31 | @dataclass |
no outgoing calls
no test coverage detected