Actually, you don’t need to modify the plugin. Create a snippet as I explain here.
After creating the
site/snippets/sitemap.page.php and copying the code from the plugin snippet, you will need to modify this part:
<?php foreach ($page->images() as $image) : ?>
<?php snippet('sitemap.image', compact('image')) ?>
<?php endforeach ?>
There you need to check if the page
module.gallery and then get the images from the children pages (modules) if so. I never tried something like this but it should work.