null check iterating over Node objects