'Find a object somewhere on the given scope stack with the given name
@param name {unicode} The name to look for
@param scopeStack {list of JSObject} The scope stack, with the outermost
(and therefore last searched) scope at the lowest index
@param type {str} The type of property to look for, e.g. "variables",
"classs", "functions"
@returns {JSObject or None} The object found, or None'

def _findScopeWithName(self, name, scopeStack, type='variables'):

    if (not name):
        return None
    log.debug('_findScopeWithName:    %r    with    name:%r    in    scopeStack:%r', type, name, scopeStack[(-1)].name)
    for scopePos in range((len(scopeStack) - 1), (-1), (-1)):
        currentScope = scopeStack[scopePos]
        namesDict = getattr(currentScope, type, None)
        if namesDict:
            foundScope = namesDict.get(name)
            if foundScope:
                log.debug('Found    %r    in    scope:%r(%s)', name, currentScope.name, currentScope.cixname)
                return foundScope
    log.debug('NO    scope    found    for:    %r', name)
    return None
