Fix fatal typo ignoring potential change in the content of maps

(cherry picked from commit 55576ee33351d4c98d92b05a62a0920596955d50)

This also happens coincidentally (!) to fix ROOT-6064.