index.js
function getDeepRelationship(payload, parentResource, deepKey) {
  var path = deepKey.split('.');
  var subResources = parentResource;
  for (var i = 0; i < path.length; i++) {
    if (Array.isArray(subResources)) {
      subResources = subResources.reduce(function (results, subResource) {
        return results.concat(
          subResource && getRelationship(payload, subResource, path[i])
        );
      }, []);
    }
    else {
      subResources = subResources && getRelationship(payload, subResources, path[i]);
    }
  }
  return subResources;
}
function getDeepRelationship(payload, parentResource, deepKey) {
  var path = deepKey.split('.');
  var subResources = parentResource;
  for (var i = 0; i < path.length; i++) {
    if (Array.isArray(subResources)) {
      subResources = subResources.reduce(function (results, subResource) {
        return results.concat(
          subResource && getRelationship(payload, subResource, path[i])
        );
      }, []);
    }
    else {
      subResources = subResources && getRelationship(payload, subResources, path[i]);
    }
  }
  return subResources;
}
function getDeepRelationship ( payload , parentResource , deepKey ) { var path = deepKey . split ( '.' ) ; var subResources = parentResource ; for ( var i = 0 ; i < path . length ; i ++ ) { if ( Array . isArray ( subResources ) ) { subResources = subResources . reduce ( function ( results , subResource ) { return results . concat ( subResource && getRelationship ( payload , subResource , path [ i ] ) ) ; } , [ ] ) ; } else { subResources = subResources && getRelationship ( payload , subResources , path [ i ] ) ; } } return subResources ; }
Fetches specified related data associated to a resource,
and related data assocociated to that included resource...

@param {Object} payload
The payload encapsulating the included data
@param {Object} parentResource
The first resource to find included data for
@param {String} deepKey
The relationship to included data to retrieve, delimited by periods.

@return {Array|Object|undefined}
The found included data object(s) or undefined if the requested included
data is not part of the API response
Fetches specified related data associated to a resource and related data assocociated to that included resource ...