`if (ref && requiredModels.indexOf(ref) < 0) {` can probably be replaced with `if (_.contains(requiredModels, ref))`