void (List<String> list) { while(list.size() > 2) { long count = 0L; for (String x : list) { if (x != null) { if (x.startsWith("x")) { count++; } } } if (!(count > 10 && list.size() < 10)) break; list = process(list); } }