'Find a hit for the first part of the tokens.
Returns (<hit>, <num-tokens-consumed>) or (None, None) if could
not resolve.
Example for \'os.sep\':
tokens: (\'os\', \'sep\')
retval: ((<variable \'sep\'>,  (<blob \'os\', [])),   1)
Example for \'os.path\':
tokens: (\'os\', \'path\')
retval: ((<import os.path>,  (<blob \'os\', [])),   2)'

def _hit_from_first_part(self, tokens, scoperef):

    first_token = tokens[0]
    self.log("find    '%s    ...'    starting    at    %s:", first_token, scoperef)
    if (first_token == '__builtins__'):
        scoperef = (self.built_in_blob, [])
        return ((self.built_in_blob, scoperef), 1)
    while 1:
        elem = self._elem_from_scoperef(scoperef)
        if (first_token in elem.names):
            self.log("is    '%s'    accessible    on    %s?    yes:    %s", first_token, scoperef, elem.names[first_token])
            return ((elem.names[first_token], scoperef), 1)
        if (first_token == elem.get('name')):
            self.log("is    '%s'    accessible    on    %s?    yes:    %s", first_token, scoperef, elem)
            return ((elem, scoperef), 1)
        (hit, nconsumed) = self._hit_from_elem_imports(tokens, elem)
        if (hit is not None):
            self.log("is    '%s'    accessible    on    %s?    yes:    %s", '.'.join(tokens[:nconsumed]), scoperef, hit[0])
            return (hit, nconsumed)
        self.log("is    '%s'    accessible    on    %s?    no", first_token, scoperef)
        scoperef = self.parent_scoperef_from_scoperef(scoperef)
        if (not scoperef):
            return (None, None)
