function removeStacktrace(data) {
  if (util.types.isNativeError(data)) {
    if (global.NODE_ENV !== "development") {
      data.stack = undefined;
    } else {
      data.stack = data.stack.split("\n").map(hilightUserCode).join("\n");
    }
  } else if (data && data.content && data.content.error) {
    // @todo v3: stack should be removed only for "production" env
    if (global.NODE_ENV !== "development") {
      data.content.error.stack = undefined;
    } else {
      data.content.error.stack = data.content.error.stack
        ? data.content.error.stack.split("\n").map(hilightUserCode).join("\n")
        : undefined;
    }
  }

  return data;
}
utility method: must be invoked by all protocols to remove stack traces
from payloads before sending them
@param  {Error|Object} data - expected: plain error object or serialized
                              request response
@returns {*} return the data minus the stack trace