This works for most situations, however if you have:
A
|-> B
|--> CAnd only A and C are selected, C will be shown nested under A, instead
being by its side.
I still have to think on how to address these cases since they are
slightly misleading.
Related: T65263.