The refactoring engine essentially does that. The visitor is a big #collect: over the AST and each visit-method returns a new/modified element. I think this is the most natural thing to do in most cases.
Do you have some pointers to classes and methods. I have trouble finding a visitor that does this on a bigger structure.