boolean (Set<File> ancestors, File file) { if (ancestors.isEmpty()) { return false; // optimization } File current = file; while (current != null) { if (ancestors.contains(current)) { return true; } current = FileUtilRt.getParentFile(current); } return false; }