implementation of cloneDeep

see #455 
I imagine you named the arguments to make this code self-documenting, but I don't think it necessary: one can scroll down a few lines to see the parameter names.