function copy(_, obj, refs, parent, resolve, callback) {
    var target =  Array.isArray(obj) ? [] : {};

    if (typeof obj.$ref === 'string') {
      var id = obj.$ref;
      var base = helpers.getDocumentURI(id);
      var local = id.indexOf('#/') > -1;

      if (local || (resolve && base !== parent)) {
        var fixed = findReference(id, refs, callback);

        deepExtend_1(obj, fixed);

        delete obj.$ref;
        delete obj.id;
      }

      if (_[id]) {
        return obj;
      }

      _[id] = 1;
    }

    for (var prop in obj) {
      if (typeof obj[prop] === 'object' && obj[prop] !== null && !helpers.isKeyword(prop)) {
        target[prop] = copy(_, obj[prop], refs, parent, resolve, callback);
      } else {
        target[prop] = obj[prop];
      }
    }

    return target;
  }
if new value isn't object then just overwrite by new value
instead of extending.