'Find the token at the given or a parent scope.
Returns the found elem and the scope at which it was found. If
not found, this returns (None, None).'

def _hit_from_first_token(self, token, scoperef):

    self.log("find    '%s'    starting    at    %s", token, scoperef)
    try:
        elem = self._elem_from_scoperef(scoperef)
    except KeyError as ex:
        self.warn('_hit_from_first_token::    no    elem    for    scoperef:    %r', scoperef)
        return (None, None)
    if (elem.get('ilk') == 'class'):
        class_name = elem.get('name')
        try:
            ctor = elem.names[class_name]
        except KeyError:
            pass
        else:
            if ('__ctor__' in ctor.get('attributes', '')):
                scoperef = (scoperef[0], (scoperef[1] + [class_name]))
                self.log('push    scope    to    class    ctor    %s', scoperef)
    started_in_builtin_window_scope = ((scoperef[0] is self.built_in_blob) and scoperef[1] and (scoperef[1][0] == self._global_var))
    while 1:
        try:
            elem = self._elem_from_scoperef(scoperef)
        except KeyError as ex:
            raise EvalError(('could    not    resolve    scoperef    %r:    %s' % (scoperef, ex)))
        try:
            candidate = elem.names[token]
            if ('__ctor__' in candidate.get('attributes', '')):
                raise KeyError('skipping    JavaScript    ctor')
            self.log("is    '%s'    accessible    on    %s?    yes", token, scoperef)
            return (candidate, scoperef)
        except KeyError:
            self.log("is    '%s'    accessible    on    %s?    no", token, scoperef)
            scoperef = self.parent_scoperef_from_scoperef(scoperef, started_in_builtin_window_scope)
            if (not scoperef):
                return (None, None)
