code: function traverse(value, cbs) {
    cbs = cbs || {};
  
    if (Array.isArray(value)) {
      if (cbs.beforeArray) value = cbs.beforeArray(value, cbs);
  
      value = value.map(function(v) {
        return traverse(v, cbs);
      });
  
      if (cbs.afterArray) value = cbs.afterArray(value, cbs);
    } else if (typeof value === 'object') {
      if (cbs.beforeObject) value = cbs.beforeObject(value, cbs);
  
      Object.keys(value).forEach(function(key) {
        value[key] = traverse(value[key], cbs);
      });
  
      if (cbs.afterObject) value = cbs.afterObject(value, cbs);
    }
  
    return value;
  }
docs: Traverse object.