for(int deg = degree; deg > 0; deg--){
filtered = (MultiPolygon) poly.clone();
filtered.apply(new ComponentMovingAverageFilter(deg, preserve));
if(filtered.isValid()){
ConnectedInteriorTester t1 = new ConnectedInteriorTester(null);
System.err.println("Applied filter degree: " + deg);
break;
}
}