From: Gerard Cahill Date: 2011-03-30T18:37:28+09:00 Subject: Re: NoMethodError: undefined method `traverse' for nil:NilClass You're invoking a method on a nil object causing a runtime error (i.e the nil class does not define a method 'traverse'). Try checking the object first before calling the method. Something simple like: unless node.nil? should do it. In 7stud's example, the variable 'data' is nil so calling a method on it, in this case 'each', raises the same error.