code: public static <T> Collection<T> unique(Collection<T> self, boolean mutate) {
          List<T> answer = new ArrayList<T>();
          for (T t : self) {
              boolean duplicated = false;
              for (T t2 : answer) {
                  if (coercedEquals(t, t2)) {
                      duplicated = true;
                      break;
                  }
              }
              if (!duplicated)
                  answer.add(t);
          }
          if (mutate) {
              self.clear();
              self.addAll(answer);
          }
          return mutate ? self : answer ;
      }
docs: Remove all duplicates from a given Collection using the default comparator.
  If mutate is true, it works by modifying the original object (and also returning it).
  If mutate is false, a new collection is returned leaving the original unchanged.
  <pre class="groovyTestCase">
  assert [1,3] == [1,3,3].unique()
  </pre>
  <pre class="groovyTestCase">
  def orig = [1, 3, 2, 3]
  def uniq = orig.unique(false)
  assert orig == [1, 3, 2, 3]
  assert uniq == [1, 3, 2]
  </pre>
  
  @param self a collection
  @param mutate false will cause a new list containing unique items from the collection to be created, true will mutate collections in place
  @return the now modified collection
  @since 1.8.1