After some discussion on IRC, @mjura made me understand I'm wrong :-) But we can use nodes.select instead of nodes.map to remove the need for delete_if.