code: public static ClassNode pickGenericType(ClassNode type, int gtIndex) {
          final GenericsType[] genericsTypes = type.getGenericsTypes();
          if (genericsTypes==null || genericsTypes.length<gtIndex) {
              return ClassHelper.OBJECT_TYPE;
          }
          return genericsTypes[gtIndex].getType();
      }
docs: A helper method which will extract the n-th generic type from a class node.
  @param type the class node from which to pick a generic type
  @param gtIndex the index of the generic type to extract
  @return the n-th generic type, or {@link org.codehaus.groovy.ast.ClassHelper#OBJECT_TYPE} if it doesn't exist.