My first 3 cracks at type-safe visitors all failed. In exciting and sometimes colorful ways (including one code-base that made it through javac but class-casted at runtime!) I've come up with another way to represent visitors, with one visitor type for each tree node type. This is closer to the ML data-structure switching stuff. However, it's more verbose. On the other hand, it is vastly configurable and perhaps may be typesafe.