fix bug of deleting the root

when deleting the root, the root does not have a parent, so additional judgement is needed.