A utility function that safely removes all child nodes of a given DOM element, avoiding the use of innerHTML.