code: function expandResource(expandedFields, resource, query, dataStore) {
    if (resource instanceof CollectionResource) {
      resource.items.forEach(function (instance) {
        expandResource(expandedFields, instance, query, dataStore);
      });
  
      return resource;
    }
  
    expandedFields.forEach(function(fieldName) {
      var path = getPathForResourceName(fieldName);
      if (typeof resource[fieldName] !== 'undefined' && fs.existsSync(path) ) {
        resource[fieldName] = instantiate(require(path), resource[fieldName], query, dataStore);
      }
    });
  
    return resource;
  }
docs: @private
  
  @description
  Given an instantiated resource or resource collection, turns all objects
  that came from an `expand` query into resource object by instantiating them.
  These transformations are done in-place (the original resource is modified,
  not copied).
  
  @param expandedFields A list of resources that were demanded in an expand query
  @param resource An instantiated parent resource or collection of resources
  @param query any query that was provided to the server when acquiring the data
  @param dataStore the dataStore used by the resource to communicate with the server. required for all resources.
  @returns Resource with expanded fields transformed into instantied resources