fixed delete function (only for tree)