Add "removeDeadNodes" function