[6] Fix infinite loop for IME processing

Previously, some Winscope traces and ADB captures will go into an
infinite loop after IME processing was introduced.
The issue was a loop in filtering the SF Layer node that did not
account for multi-windowing mode or cases where the expected parent
could not be found. This commit fixes this issue.

Bug: 236679852
Test: manual with previously failing traces
Change-Id: I8d3fe42802efa195926b5be0d4242a0bb0696988
2 files changed