I used tree interning here, because the interner already contains the necessary locks to make it Sync, and I was lazy. Be my guest if you want to do something else.
The computational overhead of interning the ASTs here is negligible, since this is all CLI code anyway.