private List<List<Integer>> helper(int[] num, int idx) {

    List<List<Integer>> result = new ArrayList<List<Integer>>();

    if (idx < 0) {
      List<Integer> empty = new ArrayList<Integer>();
      result.add(empty);
      return result;
    }

    List<List<Integer>> prev = helper(num, idx - 1);
    List<List<Integer>> curt = new ArrayList<List<Integer>>();

    for (List<Integer> prevList : prev) {

      @SuppressWarnings("unchecked")
      ArrayList<Integer> al = (ArrayList<Integer>) ((ArrayList<Integer>) prevList).clone();
      al.add(num[idx]);
      if (!prev.contains(al)) {
        curt.add(al);
      }
    }

    result.addAll(prev);
    result.addAll(curt);
    return result;
  }