// f : Concept -> Concept static Concept conceptGraphMap_aggressive(Concept c, O f) { ret conceptGraphMap_aggressive_impl(c, f, new IdentityHashMap); } static Concept conceptGraphMap_aggressive_impl(Concept c, O f, IdentityHashMap seen) { if (seen.containsKey(c)) ret seen.get(c); Concept d = cast callF(f, c); if (d != c) { Concept last = c; while (d != last && d != null) { last = d; d = (Concept) callF(f, d); } } if (d == null) { seen.put(c, null); null; } Concept e = cnew(d.getClass()); seen.put(c, e); for (S field : conceptFields(d)) { O val = cget(d, field); if (!val instanceof Concept) cset(e, field, val); else cset(e, field, conceptGraphMap_aggressive_impl(val/Concept, f, seen)); } ret e; }