Question
Machines form a rooted tree and may communicate only with their parent or children. Implement message handling so the root can count all machines and reconstruct a deterministic topology string.
```python
class Machine:
def receive_message(self, sender_id: int, message): ...
```
## Requirements
- A count request propagates to children; a leaf replies `1`; an internal node replies with one plus all child counts.
- A topology request produces `id(child1,child2,...)`; a leaf is `id[]`.
- Only the root publishes the final result.
- Correlate replies with operation type and wait for every expected child exactly once.
- Do not assume child replies arrive in order; sort by child ID for deterministic topology.
- Avoid blocking the message handler and state behavior for duplicate requests.
For a tree with edges `1->{2,3}`, `2->{4,5}`, `3->{6}`, produce `1(2(4[],5[]),3(6[]))`.
## Follow-ups
1. Add retries and deduplication for lost messages.
2. Handle nodes joining or leaving during an operation.
3. Support concurrent aggregation requests.
4. Detect cycles or a partitioned subtree.