For this to work, the first argument should be casted to an union of all the types you plan to visit. ASTs are regarded as immutable. If you return a transformed node from a visitor, then all parents ...