Remove duplicates from library root.

Closes #708
Merge 'dz0ny/bug/fix-708-duplicate' into develop
core: Use a set to get unique dirs, and sorted to make the output stable