Test and fix for second grandchild bug.

Bug is, second grandchild of a given child will get cast to the child
rather then the grandchild.