Modmanager removing duplicates: Use a standard looping pattern.

This is hopefully easier to understand and this piece of code is not
critical for performance, so let's just have it written as easy as possible.
Merge pull request #1109 from stefanbeller/modmanagerfix2

Modmanager removing duplicates: Use a standard looping pattern.