Fix emulator freeze due to infinite loop

When probing items in the PointerSet, current implementation
gets stuck in an infinite loop, sometimes. This commit breaks
the loop when it detects that each item has already been visited.

Change-Id: Ie9b00ca39395f2c8555069ff8c1048ea381bfe33
(cherry picked from commit 70166d63b0f6a2196dafc84dd253fe6f7a3fab76)
(cherry picked from commit d3d143b238b903168696b498e9834adb05a9dd97)
Merge "Fix emulator freeze due to infinite loop" into studio-1.0-release