void (Object element, List<Object> result) { if (element instanceof Application) { for (LibraryTable table : getLibraryTables(myProject, myShowCustomLibraryTables)) { if (hasLibraries(table)) { result.add(table); } } } else if (element instanceof LibraryTable) { Collections.addAll(result, getLibraries((LibraryTable)element)); } }