(Box t, Consumer<Box> b, LinkedHashSet<Box> visited)
| 250 | LinkedHashSet<Box> visited = new LinkedHashSet<>(); |
| 251 | _forEach(this, b, visited); |
| 252 | } |
| 253 | |
| 254 | static private void _forEach(Box t, Consumer<Box> b, LinkedHashSet<Box> visited) { |
| 255 | if (visited.contains(t)) return; |
| 256 | if (t.disconnected) return; |
| 257 | b.accept(t); |
| 258 | visited.add(t); |
| 259 | for (Box c : new ArrayList<>(t.children)) |
| 260 | _forEach(c, b, visited); |
| 261 | for (Box c : new ArrayList<>(t.parents)) |
| 262 | _forEach(c, b, visited); |
| 263 | } |
| 264 |