Added the cast function to cast a term to an equal type. Example with "bundled" group structure.