Added a condition to catch undefined nodes which are referenced via the parent field incorrectly.