Sanhedrin 27-2: Children Punished for Father's Sins

Why do we find Tzadikim being punished for previous generations' transgressions?