Protect a11y cache against loops in node hierarchy

Plugging a hole where we would recycle a node that is its
own ancestor twice if it was a descendant of the last
child we iterated over.

Bug: 112549653
Test: Adding new test case that reproduced the issue before
and now passes.

Change-Id: I6afc83655d4d7ca1c01f21703c8f9f9ac23e4ac6
2 files changed