What do you think about (since we never want stuff inside the node_modules dir) :

```javascript
                if (internalFileName.match('package.json') && !internalFileName.match('node_modules')) {
                    jsonfile = (jsonfile ? (exports.pathDept(internalFileName) < exports.pathDept(jsonfile) ? internalFileName : jsonfile) : internalFileName);
                    package_path = path.normalize(jsonfile.split('package.json')[0] || './' );
                }
```

and port into a exported function
```javascript
    exports.pathDept = function(absolutePath) {
        return absolutePath.split(path.sep).length;
    };
```

just to keep it consistent (and testable, I know there are no tests atm...)