':type nums: List[int]
:rtype: List[List[int]]'

def subsetsWithDup(self, nums):

    nums.sort()
    result = [[]]
    previous_size = 0
    for i in xrange(len(nums)):
        size = len(result)
        for j in xrange(size):
            if ((i == 0) or (nums[i] != nums[(i - 1)]) or (j >= previous_size)):
                result.append(list(result[j]))
                result[(-1)].append(nums[i])
        previous_size = size
    return result
