@ SuppressWarnings ( "unchecked" ) public static < T > int count ( T list ) { if ( list == null ) { return 0 ; } else if ( list instanceof Pair ) { return 1 + count ( ( ( Pair < T , T > ) list ) . second ) ; } else { return 1 ; } }
Counts the number of elements in an isomorphic list .