def uniq(a):
    """
    Removes duplicates from a list. Elements are ordered by the original
    order of their first occurrences.

    In terms of Python 2.4 and later, this is equivalent to list(set(a)).
    """
    if len(a) == 0:
        return []
    else:
        return [a[0]] + uniq([x for x in a if x != a[0]])