@SuppressWarnings("unchecked")
    public int compareTo(Object o) {
      if (! (o instanceof UFNode))
        return 0;
      UFNode<T> o_node = (UFNode<T>) o;
      int temp = size - o_node.size;
      if (temp != 0)
        return temp;
      else if (parent != null && o_node.parent == null)
        return 1;
      else if (parent == null && o_node.parent != null)
        return -1;
      else if (data instanceof Comparable)
        return ((Comparable<T>) data).compareTo(o_node.data);
      else
        return 1;
    }