boolean (File file, File root, FileTypeAssocTable<Boolean> table) { File current = file; //noinspection FileEqualsUsage it's ok to compare files by 'equals' here be because these files are produced by the same 'getParentFile' calls while (current != null && !current.equals(root)) { if (table.findAssociatedFileType(current.getName()) != null) { return true; } current = FileUtilRt.getParentFile(current); } return false; }