class Trees { static <K> int leaves (Tree<K> t) { return t.visit(new Tree.Visitor<K,Integer>() { public Integer branch(Integer left, Integer right) { return left + right; } public Integer leaf(K key) { return 1; } }); } }
f