IntSet (final int root, final IntSet acc) { if (acc.add(root)) { final IntSet directSubclasses = myClassToSubclasses.get(root); if (directSubclasses != null) { directSubclasses.forEach(s -> { addAllSubclasses(s, acc); }); } } return acc; }