Collection: Fix an infinite loop when encountering a NULL parent