While in GZDoom this uses the IWAD name, the same approach is a lot more problematic here because of name duplications with far more incompatible content.
So this allows targeting a group of base games instead of one specific version.
The same logic as in GZDoom applies: The root must not have any other content and the subdirectory must contain identifiable game content.
Some handling was also added to strip out macOS resource fork folders because they can contain data that can confuse file detection.
It now picks the minimum of the current formula and the one from before June 2017 - the current one was causing problems with sprites in the distance so now the old one is used as an upper bound.