'Find all hits for the first part of the tokens.
Returns a tuple ([<hit1>, <hit2>], <num-tokens-consumed>), or
(None, None) if it 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 _hits_from_first_part(self, tokens, scoperef):

    first_token = tokens[0]
    self.log("_hits_from_first_part::    find    '%s    ...'    starting    at    %s:", first_token, scoperef)
    if ('\\' in first_token):
        first_token = self._fqn_for_expression(first_token, scoperef)
        hits = self._hits_from_namespace(first_token, scoperef)
        if hits:
            nconsumed = 1
            return (hits, nconsumed)
        self.log('_hits_from_first_part::    no    namespace    hits')
        if (self.trg.type == 'namespace-members'):
            return (None, 1)
    if (first_token in ('this', 'self', 'parent', 'static')):
        self.log('_hits_from_first_part::    Special    handling    for    %r', first_token)
        elem = self._elem_from_scoperef(scoperef)
        while ((elem is not None) and (elem.get('ilk') not in ('class', 'trait'))):
            (blob, lpath) = scoperef
            if (not lpath):
                return (None, None)
            scoperef = (blob, lpath[:(-1)])
            elem = self._elem_from_scoperef(scoperef)
        if (not elem):
            return (None, None)
        self.log('_hits_from_first_part::    need    %s    for    %r', first_token, elem)
        if (first_token == 'parent'):
            first_token = elem.get('classrefs')
            self.log('_hits_from_first_part::    Special    handling    for    parent,    classref    %r', first_token)
            if (not first_token):
                return (None, None)
            tokens = ([first_token] + tokens[1:])
            scoperef = self.parent_scoperef_from_scoperef(scoperef)
        elif self._return_with_hit((elem, scoperef), 1):
            self.log('_hits_from_first_part::    %s    returning    scoperef:    %r', first_token, scoperef)
            return ([(elem, scoperef)], 1)
    while 1:
        self.log('_hits_from_first_part::    scoperef    now    %s:', scoperef)
        elem = self._elem_from_scoperef(scoperef)
        if (first_token in elem.names):
            first_token_elem = elem.names[first_token]
            if self._return_with_hit((first_token_elem, scoperef), 1):
                self.log("_hits_from_first_part::    pt1:    is    '%s'    accessible    on    %s?    yes:    %s", first_token, scoperef, first_token_elem)
                return ([(first_token_elem, scoperef)], 1)
        if (first_token == elem.get('name')):
            if self._return_with_hit((elem, scoperef), 1):
                self.log("_hits_from_first_part::    pt1:    is    '%s'    accessible    on    %s?    yes:    %s", first_token, scoperef, elem)
                return ([(elem, scoperef)], 1)
        if (elem.tag == 'scope'):
            self.log('_hits_from_first_part::    checking    namespace    aliases')
            imports = [child for child in elem if (child.tag == 'import')]
            for child in imports:
                module = child.get('module')
                symbol = child.get('symbol')
                alias = child.get('alias')
                self.log('_hits_from_first_part::    module:    %r,    symbol:    %r,    alias:    %r', module, symbol, alias)
                if ((alias == first_token) or ((alias is None) and (symbol == first_token))):
                    self.log("_hits_from_first_part::    pt2:    is    '%s'    accessible    on    %s?    yes:    %s", first_token, scoperef, child)
                    expr = ('\\%s\\%s' % (module, symbol))
                    hit = self._hit_from_citdl(expr, scoperef)
                    if hit:
                        return ([hit], 1)
                    break
            else:
                if (('\\' not in first_token) and (elem.get('ilk') == 'namespace')):
                    self.log('_hits_from_first_part::    checking    for    a    FQN    hit')
                    fqn = self._fqn_for_expression(first_token, scoperef)
                    try:
                        hit = self._hit_from_citdl(fqn, scoperef)
                        if hit:
                            return ([hit], 1)
                    except CodeIntelError:
                        pass
        self.log("_hits_from_first_part::    pt3:    is    '%s'    accessible    on    %s?    no", first_token, scoperef)
        if (len(scoperef[1]) >= 1):
            scoperef = self.parent_scoperef_from_scoperef(scoperef)
            assert (scoperef and (scoperef[0] is not None)), 'Something    is    seriously    wrong    with    our    php    logic.'
        else:
            break
    (hit, nconsumed) = self._hit_from_elem_imports(tokens, elem)
    if ((hit is not None) and self._return_with_hit(hit, nconsumed)):
        self.log("_hits_from_first_part::    pt4:    is    '%s'    accessible    on    %s?    yes,    imported:    %s", '.'.join(tokens[:nconsumed]), scoperef, hit[0])
        return ([hit], nconsumed)
    return (None, None)
