Tried visitor but manual tree traversal looks nicer.