Actually compare each version to the version of the last chosen one.
There's no guarantee that the added test case does showcase the
previous issue (it depends on the order that directory entries
are returned when iterating), but with the issue fixed it should behave
deterministically in any case.
You may want to the adopt the -SAME: {{^}} scheme I used in linux-cross.cpp
It can make sure the include paths are consecutive.