Map<Path,Object> decomposed = new HashMap<Path,Object>(structures.size());
for (Map.Entry<Path,Object> entry : structures.entrySet()) {
Object structure = entry.getValue();
Path path = entry.getKey();
// handle null specially by replacing with a Null token
if (structure == null) {
decomposed.put(path, NULL);
continue;
}
if (Types.isSimple(structure)) {
decomposed.put(path, structure);
continue;
}
Map<Path,Object> decomposedMap = decomposeStructure(structure);
for (Map.Entry<Path,Object> decomposedEntry : decomposedMap.entrySet()) {
decomposed.put(path.concat(decomposedEntry.getKey()), decomposedEntry.getValue());
}
}
return decomposed;
}