Also, might be worth giving this a name like "visitTree". Otherwise I would expect this "visit" to be a dispatch method. Usually the visitor pattern has something like:

```dart
visit(node) => node.accept(this);
```

Also I would make compact a named arg "{compact: true}", that way you can tell in the call site what the arg. Feel free to rename it as Siggi suggests.