Minor fix for mhas crashing if an attribute exists but is undefined

There was an object which had an attribute which existed but was set to undefined, and this loop was crashing.