code: public static Predicate<Matcher> preventLoops() {
          return new Predicate<Matcher>() {
              private final Set<Matcher> visited = new HashSet<Matcher>();
  
              public boolean apply(Matcher node) {
                  node = unwrap(node);
                  if (visited.contains(node)) {
                      return false;
                  }
                  visited.add(node);
                  return true;
              }
          };
      }
docs: A predicate for rule tree printing. Prevents SOEs by detecting and suppressing loops in the rule tree.
  
  @return a predicate