code: function resolveSchema(root, ref) {
    /* jshint validthis: true */
    var p = URI.parse(ref)
      , refPath = _getFullPath(p)
      , baseId = getFullPath(this._getId(root.schema));
    if (Object.keys(root.schema).length === 0 || refPath !== baseId) {
      var id = normalizeId(refPath);
      var refVal = this._refs[id];
      if (typeof refVal == 'string') {
        return resolveRecursive.call(this, root, refVal, p);
      } else if (refVal instanceof SchemaObject) {
        if (!refVal.validate) this._compile(refVal);
        root = refVal;
      } else {
        refVal = this._schemas[id];
        if (refVal instanceof SchemaObject) {
          if (!refVal.validate) this._compile(refVal);
          if (id == normalizeId(ref))
            return { schema: refVal, root: root, baseId: baseId };
          root = refVal;
        } else {
          return;
        }
      }
      if (!root.schema) return;
      baseId = getFullPath(this._getId(root.schema));
    }
    return getJsonPointer.call(this, p, baseId, root.schema, root);
  }
docs: Resolve schema, its root and baseId
  @this Ajv
  @param  {Object} root root object with properties schema, refVal, refs
  @param  {String} ref  reference to resolve
  @return {Object} object with properties schema, root, baseId