Before this, it is

head = nodes.shift
nodes = [ head ] if nodes.empty?