This is wrong: you should only set found to true if you actually found the node; please make sure to add a test for |(out-of-bounds index) in nodelist| and nodelist[(out-of-bounds index)].