void (List<String> list) { while(true) { boolean b = false; for (String x : list) { if (x != null) { if (x.startsWith("x")) { b = list.size() > 2; break; } } } if (!(b)) break; list = process(list); } }