def Q(filter_,thing):
    """
    type(filter):
    - list:  a flattened list of all searches (one list)
    - dict:  dict with vals each of which is that search

    Notes:

    [1] 'parent thing', with space, will do a descendent
    [2] this will come back 'flattened' jQuery style
    [3] returns a generator.  Use ``Ql`` if you want a list.

    """
    if isinstance(filter_, type([])):
        return flatten(*[_Q(x,thing) for x in filter_])
    elif isinstance(filter_, type({})):
        d = dict.fromkeys(list(filter_.keys()))
        #print(d)
        for k in d:
            #print(flatten(Q(k,thing)))
            d[k] = Q(k,thing)

        return d

    else:
        if " " in filter_:   # i.e. "antecendent post"
            parts = filter_.strip().split()
            r = None
            for p in parts:
                r = Ql(p,thing)
                thing = r

            return r

        else:  # simple.
            return flatten(_Q(filter_,thing))
dataset/ETHPy150Open pydata/pandas/scripts/json_manip.py/Q/original