lib/buildTree.js
function builder(fromUID, node) {


		debug('builder fromUID:%s',fromUID);

		// Create a node (or use the provided one)
		var node = node || new DepNode((packageId++).toString(), options);


		// Get the entry point module object
		var fromModule = findModule(fromUID);

		// Add entry point to the module
		node.addModule(fromModule);



		debug('    fromModule.req.length:%s', fromModule.req.length);
		// For each module dependency, add module to
		// the node
		_.each(fromModule.req, function(link) {
			var module = findModule(link.uid);

			// Duplicate : pass
			if(node.hasModule(module.uid)) return;

			if(link.async) {
				debug('        Add async module (%s) to node %s', link.uid, node.id);
				// Async : Create a child node
				node.appendChild(builder(link.uid));
			} else {
				debug('        Add sync module (%s) to node %s', link.uid, node.id);
				// Sync : add module
				node.addModule(module);
				builder(link.uid, node);
			}
		});
		return node;
	}
function builder(fromUID, node) {


		debug('builder fromUID:%s',fromUID);

		// Create a node (or use the provided one)
		var node = node || new DepNode((packageId++).toString(), options);


		// Get the entry point module object
		var fromModule = findModule(fromUID);

		// Add entry point to the module
		node.addModule(fromModule);



		debug('    fromModule.req.length:%s', fromModule.req.length);
		// For each module dependency, add module to
		// the node
		_.each(fromModule.req, function(link) {
			var module = findModule(link.uid);

			// Duplicate : pass
			if(node.hasModule(module.uid)) return;

			if(link.async) {
				debug('        Add async module (%s) to node %s', link.uid, node.id);
				// Async : Create a child node
				node.appendChild(builder(link.uid));
			} else {
				debug('        Add sync module (%s) to node %s', link.uid, node.id);
				// Sync : add module
				node.addModule(module);
				builder(link.uid, node);
			}
		});
		return node;
	}
function builder ( fromUID , node ) { debug ( 'builder fromUID:%s' , fromUID ) ; // Create a node (or use the provided one) var node = node || new DepNode ( ( packageId ++ ) . toString ( ) , options ) ; // Get the entry point module object var fromModule = findModule ( fromUID ) ; // Add entry point to the module node . addModule ( fromModule ) ; debug ( '    fromModule.req.length:%s' , fromModule . req . length ) ; // For each module dependency, add module to // the node _ . each ( fromModule . req , function ( link ) { var module = findModule ( link . uid ) ; // Duplicate : pass if ( node . hasModule ( module . uid ) ) return ; if ( link . async ) { debug ( '        Add async module (%s) to node %s' , link . uid , node . id ) ; // Async : Create a child node node . appendChild ( builder ( link . uid ) ) ; } else { debug ( '        Add sync module (%s) to node %s' , link . uid , node . id ) ; // Sync : add module node . addModule ( module ) ; builder ( link . uid , node ) ; } } ) ; return node ; }
Build a module dependency tree

@param  {string} fromUID Entry point module uniq id
@param  {DepNode|null} node parent DepNode
@return {DepNode}           A DepNode object (traversable as a DepNode tree)
@api public
Build a module dependency tree