Other nested elements are not being removed

First and foremost I am not sure if this will not break something else. I just unit tested that single function. Have not got further down the line.
Sorry my editor removed some trailing whitespace.