Destroy the given node provided by the reference.
The function will check for nodes that are null references.