This method can be cleaned up by removing every line following the point where something other than node is returned, and just returning node.