You don't actually need to do the check. delete on a nullpointer is perfectly legal (and safe).