This method seems overly complex. Can you take an audit of what's going on in here and restructure things with some comments about what is going on?

At the least, if this method starts with:

```
// Get the /api root resource
var root = that.resources[apiRootPath] = that.resources[apiRootPath] || {
    'apiVersion': swagger.constants.apiVersion,
    'swaggerVersion': swagger.constants.swaggerVersion,
    'basePath': swagger.constants.basePath,
    'resourcePath': swagger.constants.resourcePath,
    'apis': [],
    'models': {}
};
```

And implemented the rest of the method knowing that `root` exists, we've removed quite a bit of noise from the logic.