Exodus 20:5b (WLC | ESV) :
כִּ֣י אָֽנֹכִ֞י יְהוָ֤ה אֱלֹהֶ֙יךָ֙ אֵ֣ל קַנָּ֔א פֹּ֠קֵד עֲוֺ֨ן אָבֹ֧ת עַל־בָּנִ֛ים עַל־שִׁלֵּשִׁ֥ים וְעַל־רִבֵּעִ֖ים לְשֹׂנְאָֽ֑י
for I the LORD your God am a jealous God, visiting the iniquity of the fathers on the children to the third and the fourth generation of those who hate me
In another question I have a footnote giving my impression that "of those who hate me" belongs with "children". This entails that it is the fathers' God-hating that is being cited.
My ESV Study Bible and the NET notes both take pains to point out that this phrase qualifies the scope of the descendants whom God will punish -- it's only those who, in a way, follow in their fathers' footsteps. This is probably the most natural reading of the English.
My trouble is that I can't get the Hebrew to work that way. The lamed preposition is often glossed "to", but it's not unusual with בן (son, ESV child), making a periphrastic genitive I suppose, effectively possessive ("son of [lit. 'to'] X"). The translation "...of those who hate me" makes sense, but this seems to me to introduce an ambiguity, the possibility of "[generations [of those who...]]". It's not clear to me that this is an option in Hebrew, where the word generations is implied from the numbers, and the lamed preposition doesn't have a clear (to me) meaning in this context.
Is "those who hate me" here intended as a qualification of the inter-generational punishment, limiting its scope to sons guilty of this God-hating, or is it a further specification of the nature/extent of the fathers' iniquity?