### Question:
Octree { public List<T> flatten() { List<T> list = new ArrayList<T>(); Deque<Octree<T>> queue = new ArrayDeque<>(); queue.push(this); while (queue.size() > 0) { Octree<T> tree = queue.pop(); if (tree.item != null) { list.add(tree.item); } for (int oct = 0; oct < 8; ++oct) { Octree<T> o = tree.get(oct); if (o != null) queue.push(o); } } return list; } Octree();  Octree(int rootLevel); private  Octree(int level, int x, int y, int z); void clear(); void remove(int x, int y, int z, int size); void insert(int x, int y, int z, int size, T item); Octree get(int octant); int getLevel(); T getItem(); int getItemCount(); T get(int x, int y, int z, int size); List<T> flatten();  }### Answer:
@Test public void testFlatten() { Octree<String> o = new Octree<>(); o.insert(0, 0, 0, 8, "Foo"); o.insert(32, 16, 8, 4, "Bar"); List<String> f = o.flatten(); assertEquals(2, f.size()); assertTrue(f.contains("Foo")); assertTrue(f.contains("Bar")); }