Don't create group nodes which will be deleted anyway


The old code first created the nodes, then checked whether their parent
element has the right type and deleted them if not. This was wasted
effort and could also lead to dangling pointers.

Instead, first check the parent's type and only create the node if that
matches.

Task-number: QTBUG-139961
Pick-to: 6.10.0 6.10 6.9 6.8
Change-Id: Ifa870efbd5f336b34b81aa09b6fe79fb7fc826b9
Reviewed-by: Hatem ElKharashy <hatem.elkharashy@qt.io>
commit7e8898903265d931df0aa54b3913f2c49d4d7bf2
parentc4de20d0be6c25137d975e11203c2252935b876f
authorRobert Löhning <robert.loehning@qt.io>
committerRobert Löhning <robert.loehning@qt.io>
commit timeTue, 16 Sep 2025 13:00:48 +0000