private static void cleanUpCaches(SimpleNode node) {
    if (!(node instanceof CachingSimpleNode cachingNode)) return;

    SimpleNode[] cached = cachingNode.getCached();
    if (cached == null) return;

    for (SimpleNode eachChild : cached) {
      cleanUpCaches(eachChild);
    }

    cachingNode.cleanUpCache();
  }
private static void cleanUpCaches(SimpleNode node)