code: public static <T> Collection<T> toUnique(Iterable<T> self, Comparator<T> comparator) {
          Collection<T> result = createSimilarCollection((Collection<T>) self);
          addAll(result, toUnique(self.iterator(), comparator));
          return result;
      }
docs: Returns a Collection containing the items from the Iterable but with duplicates removed.
  The items in the Iterable are compared by the given Comparator.
  For each duplicate, the first member which is returned from the
  Iterable is retained, but all other ones are removed.
  <p>
  <pre class="groovyTestCase">
  class Person {
  def fname, lname
  String toString() {
  return fname + " " + lname
  }
  }
  
  class PersonComparator implements Comparator {
  int compare(Object o1, Object o2) {
  Person p1 = (Person) o1
  Person p2 = (Person) o2
  if (p1.lname != p2.lname)
  return p1.lname.compareTo(p2.lname)
  else
  return p1.fname.compareTo(p2.fname)
  }
  
  boolean equals(Object obj) {
  return this.equals(obj)
  }
  }
  
  Person a = new Person(fname:"John", lname:"Taylor")
  Person b = new Person(fname:"Clark", lname:"Taylor")
  Person c = new Person(fname:"Tom", lname:"Cruz")
  Person d = new Person(fname:"Clark", lname:"Taylor")
  
  def list = [a, b, c, d]
  List list2 = list.toUnique(new PersonComparator())
  assert list2 == [a, b, c] {@code &&} list == [a, b, c, d]
  </pre>
  
  @param self       an Iterable
  @param comparator a Comparator used to determine unique (equal) items
  If {@code null}, the Comparable natural ordering of the elements will be used.
  @return the Collection of non-duplicate items
  @since 2.4.0