Groups: more robust creation of api groups (handle empty parent groups etc)