Fixed the broken tree-from-frequency construction