return transformTree(tree);
}
public static ISerializedObjectTree transformTree(ISerializedObjectTree tree)
{
ISerializedObjectTree ret = tree;
if (!tree.children().isEmpty())
{
List<ISerializedObjectTree> transformed = new ArrayList<ISerializedObjectTree>();
for (ISerializedObjectTree t : tree.children())
{
transformed.add(transformTree(t));
}
TreeTypeMap typeMap = new TreeTypeMap(transformed);
if (typeMap.hasLessEntries(transformed.size()))
{
// LOG.error("Compress {}",tree.type());
List<ISerializedObjectTree> result = typeMap.compressedResult();
ret = new ImmutableTree(ret.id(), ret.type(), ret.label(), ret.size(), result);
// new TreeSizeReport().process(tree);
// new TreeSizeReport().process(ret);
} else {
if (!sameEntries(tree.children(), transformed)) {
ret = new ImmutableTree(ret.id(), ret.type(), ret.label(), ret.size(), transformed);
}
}
}
return ret;
}