The Maildir object itself can be iterated to loop through the messages in the top-level folder.
mbox = mailbox.Maildir(dirpath, create=False)
for msg in mbox.itervalues():
...
or just:
for msg in mbox:
...
https://docs.python.org/3/library/mailbox.html#maildir-objects