public Void visitOther(Tree expected, Tree actual) {
throw new UnsupportedOperationException("cannot compare unknown trees");
}
private <T extends Tree> Optional<T> checkTypeAndCast(T expected, Tree actual) {
Kind expectedKind = checkNotNull(expected).getKind();
Kind treeKind = checkNotNull(actual).getKind();
if (expectedKind == treeKind) {
@SuppressWarnings("unchecked") // checked by Kind
T treeAsExpectedType = (T) actual;
return Optional.of(treeAsExpectedType);
} else {