This save/set/restore is awkward.  Why not deep clone and set instead?  This is a cache miss so performance doesn't matter.