'Resolve the first part of the expression.
If the first token is found at the global or built-in level (or
not found at all locally) then it may be a shared namespace with
other files in the execution set. Get that down to a list of
hits and a remaining list of expression tokens.'

def _hits_from_first_part(self, tokens, scoperef):

    (elem, scoperef) = self._hit_from_first_token(tokens[0], scoperef)
    if (elem is not None):
        self.log('_hit_from_first_part:    found    elem:    %s    %r    at    %r', (elem.get('ilk') or elem.tag), elem.get('name'), scoperef[1])
    if ((elem is None) or (not scoperef[1]) or ((scoperef[1] == ['Window']) and (scoperef[0].get('name') == '*'))):
        for (first_call_idx, token) in enumerate(tokens):
            if (token == '()'):
                break
        else:
            first_call_idx = len(tokens)
        hits = []
        for nconsumed in range(first_call_idx, 0, (-1)):
            lpath = tuple(tokens[:nconsumed])
            if ((elem is not None) and (len(lpath) > 1)):
                try:
                    self.log('Checking    for    deeper    local    match    %r    from    scoperef    %r', lpath[1:], scoperef)
                    check_elem = elem
                    for p in lpath[1:]:
                        check_elem = check_elem.names[p]
                    check_scoperef = (scoperef[0], (scoperef[1] + list(lpath[:(-1)])))
                    hits.insert(0, (check_elem, check_scoperef))
                    self.log('_hit_from_first_part:    found    deeper    local    elem:    %s    %r    at    %r', (check_elem.get('ilk') or check_elem.tag), check_elem.get('name'), check_scoperef[1])
                except KeyError:
                    pass
            for lib in self.libs:
                self.log("lookup    '%s'    in    %s", '.'.join(lpath), lib)
                hits_here = lib.hits_from_lpath(lpath, self.ctlr, curr_buf=self.buf)
                if hits_here:
                    self.log('found    %d    hits    in    lib', len(hits_here))
                    hits += hits_here
            if hits:
                break
        if (elem is not None):
            if ((not hits) or (nconsumed == 1)):
                hits.insert(0, (elem, scoperef))
                nconsumed = 1
            else:
                new_elem = elem
                for token in tokens[1:nconsumed]:
                    try:
                        new_elem = new_elem.names[token]
                    except KeyError:
                        break
                else:
                    if (new_elem not in (e for (e, sr) in hits)):
                        new_scoperef = (scoperef[0], tokens[:(nconsumed - 1)])
                        hits.insert(0, (new_elem, new_scoperef))
    else:
        hits = [(elem, scoperef)]
        nconsumed = 1
    return (hits, nconsumed)
