Second one, I do replace node all the time.

Thinking a bit about it, I'd try reparse, get node from selection index, find equal old node in old (modified) ast, or replace old (modified) ast with new one.
Can you explain this, sorry I didn't get the point