Fix broken handling of recurse=True for modules

Also tighten up handling of packages vs. modules, and use walk_packages
rather than iter_modules to avoid unnecessary recursion in our own code
Handle a prefix of "" properly