I tried deleting everything except the tree and it still worked OK in all three ways I described above. How are you deleting the elements? At first I thought you might have a race conditions, but that looks less likely now.
A good way to hunt down a bug is to start deleting pieces of the code and seeing when the wrong behavior stops. That way you know the thing you deleted last has something to do with the bug.
___________________
Try to take over the world!