free memory of deleted nodes