Here you can find the source of flattenForest(Collection forest)
public static Collection flattenForest(Collection forest)
//package com.java2s; //License from project: Open Source License import java.util.Collection; import java.util.Iterator; import java.util.LinkedHashSet; public class Main { public static Collection flattenForest(Collection forest) { final Collection ret = new LinkedHashSet(); for (final Iterator it = forest.iterator(); it.hasNext();) { final Collection set = (Collection) it.next(); ret.addAll(set);// w w w . j a v a2s .c om } return ret; } }