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