@Tschanzt I think it is better if you use portal_catalog.uniqueValuesFor("Subject"). This already does everything you want. 
And pls add a test for this feature.