package example;
class Size{
  static public <a> int size(Tree<a> t){
    if (t instanceof Empty) return 0;
    if (t instanceof Branch<a>) {
      Branch<a> dies = (Branch<a>) t;
      return
         1+size(dies.getLeft())
          +size(dies.getRight());
    }
    throw new RuntimeException("unmatched pattern: "+t);
  };
  public static void main(String [] _){
    System.out.println(size(
     new Branch<String>(new Empty<String>()
                       ,"hallo"
                       ,new Empty<String>())));
  }
}