// returns visited objects // visitor may be null, then it's just about returning the set static Set philosophyBot1_visitTrailsTree_gen(virtual PhilosophyBot1 engine, IVF1 visitor, O startingPoint) { new Set seen; philosophyBot1_visitTrailsTree_gen(engine, seen, visitor, startingPoint); ret seen; } svoid philosophyBot1_visitTrailsTree_gen(virtual PhilosophyBot1 engine, Set seen, IVF1 visitor, O startingPoint) { if (startingPoint == null) ret; if (!seen.add(startingPoint)) ret; visitor?.get(startingPoint); if (startingPoint cast Iterable) for (O o : startingPoint) philosophyBot1_visitTrailsTree_gen(engine, seen, visitor, o); else if (startingPoint cast Map) for (O o : values(startingPoint)) philosophyBot1_visitTrailsTree_gen(engine, seen, visitor, o); else philosophyBot1_visitTrailsTree_gen(engine, seen, visitor, rcall getTrail(engine, startingPoint)); }