Fixed bug in finding previous node.