for ( ModuleDefinition def : defs ) {
modules.put(def.getName(), def);
}
ModuleDefinition rootDef = null;
Map<String, ModuleDefinition> result = new HashMap<String, ModuleDefinition>();
for ( ModuleDefinition def : modules.values() ) {
if ( def.getName().equals(root) ) {
rootDef = def;
}
if ( def.getParentName() != null ) {
ModuleDefinition parentDef = modules.get(def.getParentName());
if ( parentDef != null )
parentDef.addChild(def);
}
}
return traverse(rootDef, result);
}