There is a bug in DefUseChains with nested loops where the same loop can occur multiple times.
Helpfully the comment in the code says:
# We will only ever reach a reference once, so
# we don't need to check uniqueness.
at line 367, which seems to be incorrect, so we just need a uniqueness check here.