Revert "Revert "Revert "Prevent NRE when x.Attribute returns null"""

This reverts commit e0a6462ab863c19062385b7b1373c0861220412d.