code: @SuppressWarnings("unchecked")
      public static <T> int traverse(T list, Functor<?, T> func) {
          if (list == null) {
              return 0;
          } else if (list instanceof Pair) {
              Pair<T, T> pair = (Pair<T, T>)list;
              func.invoke(pair.first);
              return 1 + traverse(pair.second, func);
          } else {
              func.invoke(list);
              return 1;
          }
      }
docs: Traverses an isomorphic list using a Functor. The return values from the functor are discarded.
  
  @param <T> the type of the elements in the isomorphic list
  @param list - a list represented by the first Pair object isomorphic to the elements, or an element when the list is trivial
  @param func - a functor that will be invoked to inspect the elements, one at a time
  @return the number of elements traversed