def _unwind(cons, quantifiers = {}):
    """Unwind a nested LISP-style list to a Python-style
    data structure.

    The quantifiers argument is used to choose between a list
    representation (if max occurence count > 1) or a scalar
    value (max occurence count == 1).

    Example:
      unwind( (('x', 1), (('y', 2), (('x', 3), ()))) ) 
       => { 'x':[1,3], 'y':[2] }
    """
    result = {}
    while cons:
        (k,v), cons = cons
        
        entry = result.setdefault(k, [])
        entry.append(v)

    for k, v in result.items():
        if quantifiers.get(k , (0,9999))[1] == 1:
            result[k] = v[0]
        else:
            result[k] = v[::-1]

    return result