public static List treeToList(Listlist) { List result = new ArrayList<>(); for(T test : list) { List c = test.getChildren(); result.add(test); if (!CollectionUtils.isEmpty(c)) { result.addAll(treeToList(c)); test.setChildren(null); } } return result; }



