Fix dependency tracking for package imports.

We were previously relying on direct name-based `sys.modules` lookups
to resolve module references.  This was an attempt to work around
__import__()'s behavior of returning the package object for an import
in the form `import package.module` (instead of the module itself).

Unfortunately, the import names did not always match the module names,
causing some of this lookups to fail.  This resulted in an incomplete
dependency map.

We now manually walk through the the imported module hierarchy to more
definitively locate the desired module object.

Closes #15