rework remove function and verification of tree on remove