function scanTreeForNodesModules(moduleName) {
    let coreNodesDir = settings.coreNodesDir;
    let results = [];
    let userDir;
    let nodesDir;
    if(settings.nodesDir) {
        nodesDir = Array.isArray(settings.nodesDir) ? settings.nodesDir : [settings.nodesDir]
    }
    if (settings.userDir) {
        packageList = getPackageList();
        userDir = path.join(settings.userDir,"node_modules");
        results = scanDirForNodesModules(userDir,moduleName);
        results.forEach(function(r) {
            // If it was found in <userDir>/node_modules then it is considered
            // a local module.
            // Also check to see if it is listed in the package.json file as a user-installed
            // module. This distinguishes modules installed as a dependency
            r.local = true;
            r.user = !!packageList[r.package.name];
        });
    }

    if (coreNodesDir) {
        var up = path.resolve(path.join(coreNodesDir,".."));
        while (up !== coreNodesDir) {
            var pm = path.join(coreNodesDir,"node_modules");
            if (pm != userDir) {
                results = results.concat(scanDirForNodesModules(pm,moduleName));
            }
            coreNodesDir = up;
            up = path.resolve(path.join(coreNodesDir,".."));
        }
    }

    // scan nodesDir for any node-red modules
    /*
    1. if !exist(package.json) || !package.json.has(node-red) => look for node_modules
    2. exist(package.json) && package.json.has(node-red) => load this only
    3. in original scan of nodesDir, ignore if:(exist(package.json) && package.json.has(node-red)) 
    */
    if (nodesDir) {
        for (let dirIndex = 0; dirIndex < nodesDir.length; dirIndex++) {
            const nodeDir = nodesDir[dirIndex];
            const packageDetails = getPackageDetails(nodeDir)
            if(packageDetails.isNodeRedModule) {
                //we have found a node-red module, scan it
                const nrModules = scanDirForNodesModules(nodeDir, packageDetails.package.name, packageDetails);
                results = results.concat(nrModules);

            } else if (packageDetails.has_node_modules) {
                //If this dir has a `node_modues` dir, scan it
                const nodeModulesDir = path.join(nodeDir, 'node_modules')
                const nrModules = scanDirForNodesModules(nodeModulesDir, moduleName );
                results = results.concat(nrModules);

            } else {
                //If this is not a node-red module AND it does NOT have a node_modules dir,
                //it may be a directory of project directories or a node_modules dir?
                //scan this instead
                const nrModules = scanDirForNodesModules(nodeDir, moduleName);
                results = results.concat(nrModules);
            }
        }
    }
    return results;
}
Scans the node_modules path for nodes
@param moduleName the name of the module to be found
@return a list of node modules: {dir,package}