Ignorable nit: would `return max([...for group in groups]) if groups else 0` be more readable?