Refactor for 5027 -- get rid of lookup_qualified_var
Scope#lookup_qualified_var was a "magic bag" that took a qualified variable
name apart and called back in to lookupvar with a new scope. This commit is
a semantically neutral refactor that replaces it with a function to find the
desired scope as a pure function (with error detection).