'Construct a Storage of S3ResourceQuery from a Storage of get_vars
@param resource: the S3Resource
@param vars: the get_vars
@return: Storage of S3ResourceQuery like {alias: query}, where
alias is the alias of the component the query concerns'

@classmethod
def parse(cls, resource, vars):

    query = Storage()
    if (resource is None):
        return query
    if (not vars):
        return query
    subquery = cls._subquery
    allof = (lambda l, r: (l if (r is None) else (r if (l is None) else (r & l))))
    for (key, value) in vars.iteritems():
        if (not key):
            continue
        elif (key == '$filter'):
            parser = S3URLQueryParser()
            if (parser.parser is None):
                continue
            expressions = (value if (type(value) is list) else [value])
            default_alias = resource.alias
            for expression in expressions:
                parsed = parser.parse(expression)
                for alias in parsed:
                    q = parsed[alias]
                    qalias = (alias if (alias is not None) else default_alias)
                    if (qalias not in query):
                        query[qalias] = [q]
                    else:
                        query[qalias].append(q)
            continue
        elif ((key[0] == '_') or (not (('.' in key) or ((key[0] == '(') and (')' in key))))):
            continue
        (selectors, op, invert) = cls.parse_expression(key)
        if (type(value) is list):
            q = reduce(allof, [subquery(selectors, op, invert, v) for v in value], None)
        else:
            q = subquery(selectors, op, invert, value)
        if (q is None):
            continue
        if (len(selectors) > 1):
            aliases = [s.split('.', 1)[0] for s in selectors]
            if (len(set(aliases)) == 1):
                alias = aliases[0]
            else:
                alias = resource.alias
        else:
            alias = selectors[0].split('.', 1)[0]
        if (alias == '~'):
            alias = resource.alias
        if (alias not in query):
            query[alias] = [q]
        else:
            query[alias].append(q)
    return query
