"Remove Unused Variables" incorrectly removes variables that have a shared scope

I guess this is a bug: (UIPath Studio version: 2019.10.4)

Issue:

“Remove Unused Variables” incorrectly removes variables from processes with activities that run in the same scope as the parent (e.g. For Each)

Steps to reproduce:

Problem:

The process breaks (escalation marks) with:

Main.xaml: Compiler error(s) encountered processing expression “Dict(item)”.
‘Dict’ is not declared. It may be inaccessible due to its protection level.