Grouping OMIM disease codes
Based on OMIM ID codes
In a broad sense NIH have already divided the IDs. If all you are checking is OMIM code enrichment, this might be an okay resolution since it can tell you the chromosomal locus (autosomal, sex linked, or mitochondrial).

Each OMIM entry is given a unique six-digit number as summarized below:
1----- (100000- ) 2----- (200000- ) Autosomal loci or phenotypes
(entries created before May 15, 1994)
3----- (300000- ) X-linked loci or phenotypes
4----- (400000- ) Y-linked loci or phenotypes
5----- (500000- ) Mitochondrial loci or phenotypes
6----- (600000- ) Autosomal loci or phenotypes (entries created after
May 15, 1994)

Other databases as an alternative method.
If you are interested in specific phenotypes, you may need to get more involved.
OMIM doesn't really attempt to group diseases together beyond their ID nomenclature as far as I'm aware. There have been several projects that set out to do this, like the one the question points out, and the examples below. They mostly use phenotypic data in combination with OMIM information.
Two databases that aim to solve this are:

HPO
LDDB
Enricher web-server see @MaximKuleshovs answer below!

These are tools with controlled vocabulary for phenotypes and associations from OMIM codes. They could help you check for disease/phenotype specific enrichment. This would certainly allow programmatic grouping, although I have not worked with either before and I presume it would be very involved!
It's up to you!
Wikipedia has a list of OMIM codes listed in alphabetical order if you wanted to try to group them manually by whichever criteria you desire.

Without your source code it's hard to tell, but maybe the maximum of one occurrence rate could be a code problem rather than a scientific problem.