save before rewrite
reimplement tree walking