Fixes #1062 - foreach over paths in case of duplicates