Maybe a safe traversal operator would help. Perhaps a try-catch could provide more detail about what went wrong and where.