Clean up dangling layer hierarchy references

In order to support detached mirrors, we introduced a different path for
mirroring a hierarchy that excludes the root layer's transform. However,
when the mirrored layer was destroyed, references to this layer were not
properly removed from its mirroring hierarchy. Fix this and introduce a test
to cover this scenario.

Flag: EXEMPT bug fix
Fixes: 343901186
Test: presumbit

Change-Id: I32f41fc2c9db00590ede4509d75000ab0a38f116
2 files changed