Check if node has attributes before iterating
Check if node has attributes before iterating

If the node has no attributes, `->attributes` is null which results in
errors when we try to loop through.

h/t stephenmax

ampproject/amp-toolbox-php,ampproject/amp-toolbox-php