public static <N> List<N> treeToList(Collection<N> nodeList,
                                         Function<N, Collection<N>> children) {
        List<N> list = new ArrayList<>(nodeList.size());
        flatTree(nodeList, children, list::add);
        return list;
    }
@Test
    public void testTreeToList() {

        Node node1 = new Node();
        node1.setChildren(Arrays.asList(new Node(), new Node()));

        List<Node> nodes = TreeUtils.treeToList(Collections.singletonList(node1),
                                                Node::getChildren);


        assertNotNull(nodes);
        assertEquals(3, nodes.size());

    }