Dungeon Master's Guide (page 138) presents a method for generating number of characters for each class when generating community. You need to roll dices and add community modifier to generate maximum level of given class in given community and from there
if the highest-level character indicated is 2nd level or higher, assume the community has twice that number of characters of half that level. If those characters are higher than 1st level, assume that for each such character, the community has two of half that level. Continue until the number of 1st-level characters is generated.
Above quote is for PC classes, but for NPC classes the method is similar, only 1st level characters' classes are assigned in different way.
For commoner NPC class and metropolis, there is 74,23% chance that highest level will be over 20, up to 28.
The first part of the question is:
If maximum level of NPC is generated as 21 or higher, should it be truncated to 20?
If the level should not be truncated, it is natural that level 28 commoner will generate 2 commoners at 14 level each, they will generate 4 level 7 commoners and so on. However, if the original commoner's level should be truncated to 20, should I use 20 as the base to generate lower level commoners (generating 2 commoners level 10 and so on) or still 28?
The second part of the question:
If level should be truncated as above, should I use original or truncated value to generate lower level NPC of the same class?