You cannot directly iterate a mapping or enumerate the keys that exist because all keys in a hash table do definitely exist ... it's just that most of them have 0x0 values.
You can only solve the problem by creating a structure that uses a mapping for effective random access and an array for iteration. It's up to you to maintain the structure.
Have a look at the last two suggestions here: Are there well-solved and simple storage patterns for Solidity?
The Solidity CRUD pattern has evolved a bit, now a library and of course the source code version keeps advancing. Have a look over here for a library and an explanation of what it's doing.
https://medium.com/robhitchens/solidity-crud-epilogue-e563e794fde
Hope it helps.