Prevent ClassCastException when encountering ItemGroup of
non-TopLevelItem.

This is the case for instance when encountering a MavenModuleSet which
is ItemGroup<MavenModule>
Merge branch 'master' into recurse-folders-maven-jobs-compat
Merge pull request #763 from Vlatombe/recurse-folders-maven-jobs-compat

Fix compatibility of the recurse option with Maven jobs
Thanks !