generalize categorical attribute splitter logic for any number of split groups