I'm not convinced we need this test, as ```elem_remove``` is never used below. It sounds like an optimization, but I honestly don't believe it makes a big difference here, and it instead creates some slight confusion (why do we have this test if we don't use the variable?)