delete empty branches when removing a query