```
class Solution(object):
def subsetsWithDup(self, nums):
"""
:type nums: List[int]
:rtype: List[List[int]]
"""
def helper(arr):
if not arr: return [[]]
num, i = arr[0], 1
while i < len(arr) and arr[i] == num: i += 1
return [[num]*l + subset for l in xrange(i+1) for subset in helper(arr[i:])]
return helper(sorted(nums))
```