Fix compatibility of the recurse option with Maven jobs

Prevent ClassCastException when encountering ItemGroup of non-TopLevelItem.

This is the case for instance when encountering a MavenModuleSet which
is ItemGroup<MavenModule>