code: public static <T extends HierarchyEntity<T, ?>> List<T> getRoots(final List<T> nodes) {
      List<T> roots = CollectUtils.newArrayList();
      for (T m : nodes)
        if (null == m.getParent() || !nodes.contains(m.getParent())) roots.add(m);
      return roots;
    }
docs: <p>
  getRoots.
  </p>
  
  @param nodes a {@link java.util.List} object.
  @param <T> a T object.
  @return a {@link java.util.List} object.