Added conditional for removal of child nodes.