List<File> (GenerationEnvironment data, File[] children) { List<File> files = new ArrayList<>(); List<File> dirs = new ArrayList<>(); for (File child : children) { (child.isDirectory() ? dirs : files).add(child); } if (files.isEmpty() || dirs.isEmpty()) { return Arrays.asList(children); } int ratio = Math.max(100, dirs.size() / files.size()); return data.generate(Generator.integers(0, ratio - 1)) != 0 ? dirs : files; }