### Question:
TreeCleanerVisitor extends SetsTransformerWithErrors<ParseFailedException> { @Override public Either<Set<ParseFailedException>, Term> apply(TermCons tc) { if (tc.production().isSyntacticSubsort()) { Either<java.util.Set<ParseFailedException>, Term> rez = new TreeCleanerVisitor2(tc).apply(tc.get(0)); if (rez.isLeft()) return rez; if (tc.production().klabel().isEmpty()) return apply(rez.right().get()); } else { int a = 1 + 2; } if (!tc.production().att().contains("bracket") && tc.production().klabel().isEmpty()) { return Left.apply(Sets.newHashSet(new ParseFailedException(new KException( KException.ExceptionType.ERROR, KException.KExceptionGroup.INNER_PARSER, "Only subsort productions are allowed to have no #klabel attribute", tc.source().get(), tc.location().get())))); } return super.apply(tc); }  @Override Either<Set<ParseFailedException>, Term> apply(TermCons tc); @Override Either<Set<ParseFailedException>, Term> apply(KList node);  }### Answer:
@Test public void testAmb() throws Exception { assertCleanup(Ambiguity.apply(foo), foo); }
@Test public void testAmb2() throws Exception { Ambiguity two = Ambiguity.apply(foo, bar); assertCleanup(two, two); }
@Test(expected = ParseFailedException.class) public void testNoKLabel() throws Exception { throwFirstLeftException(TermCons.apply(ConsPStack.from(Arrays.asList(bar, foo)), noKLabelProduction, new Location(0, 0, 0, 0), new Source(""))); }
@Test public void testKList() throws Exception { assertCleanup(Ambiguity.apply(KList.apply(ConsPStack.singleton(foo))), foo); }