Factor lookup() and reorganize to expose the algorithm used.

As a preliminary step toward instrumenting lookup() in scopeResolve to understand the algorithm it implements, I split it into two helper routines:
* lookup() -- Performs symbol lookup following module uses.
* lookupSimple() -- Performs symbol lookup ignoring module uses.
The logic for detecting success (exactly one symbol found) and reporting errors was pushed into the driver routine.added in Mike's recent refactoring

TODO: It might be possible to replace some of the code in lookup() with calls to lookupSimple().

[tested on / (std)]