final Map<IPath, Node> nodes = new HashMap<IPath, Node>();
for (Map.Entry<String, Change> entry : changes.entrySet()) {
String repoRelativePath = entry.getKey();
Change change = entry.getValue();
GitModelObjectContainer parent = root;
List<GitModelObject> children = rootChildren;
IPath path = rootPath;
String[] segments = repoRelativePath.split("/"); //$NON-NLS-1$
for (int i = 0; i < segments.length; i++) {
path = path.append(segments[i]);
// Changes represent files, so the last segment is the file name
boolean fileNode = (i == segments.length - 1);
if (!fileNode) {
Node node = nodes.get(path);
if (node == null) {
GitModelTree tree = treeFactory.createTreeModel(parent,
path, change.getKind());
node = new Node(tree);
nodes.put(path, node);
children.add(tree);
}
parent = node.tree;