Add tree-rewriting test