static Map simplifyWordTree(Map tree) { if (tree == null) null; ret (Map) simplifyWordTree_impl(tree, true); } static O simplifyWordTree_impl(O tree, bool keepAsMap) { if (tree instanceof S) ret tree; Map m = cast tree; if (!keepAsMap && l(m) == 1 && eq(firstKey(m), "")) ret (S) firstValue(m); Map map = similarEmptyMap(m); for (S key, O value : m) { map.put(key, simplifyWordTree_impl(value, false)); } ret map; }