Deep clone an object
@param {object} obj
@returns {object}
function deepClone(obj) {
  if (obj == null || typeof obj !== 'object') {
    return obj;
  }
  var cloned = obj.constructor();
  for (var key in obj) {
    if (obj.hasOwnProperty(key)) {
      cloned[key] = deepClone(obj[key]);
    }
  }
  return cloned;
}