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)
Merge "Fix emulator freeze due to infinite loop" into studio-1.0-dev
Merge "Fix emulator freeze due to infinite loop" into studio-1.0-dev
automerge: c71c5bb

* commit 'c71c5bbf8d190aa40c9bb7f6d42ba4c005ecae4c':
  Fix emulator freeze due to infinite loop