human
I found an interesting problem on https://leetcode.com/problems/subsets-ii/:
Given a collection of integers that might contain duplicates, nums, return all possible subsets (the power set).

Note: The solution set must not contain duplicate subsets.

Example:

Input: [1,2,2]
Output:
[
  [2],
  [1],
  [1,2,2],
  [2,2],
  [1,2],
  []
]

I tried it in Python, but could not do it. Can you solve it?
assistant
#Here is the Python program you requested.

class Solution:
     def subsetsWithDup(self, nums):
         """
         :type nums: List[int]
         :rtype: List[List[int]]
         """
         result = []
         res = []
         
         self.df(nums, 0, result, res)
         return res
     
     def df(self, nums, idx, result, res):
         if idx > len(nums):
             return
         if result not in res:
             res.append(result)
         
         for i in range(idx, len(nums)):
             self.df(nums, i+1, sorted(result + [nums[i]]), res)