Avoid overwriting of falsy attributes in readAttribute

Do not unconditionally overwrite the last data
part with an empty hash, similar to how it is handled
for remove and writeAttribute
Fix localisation lookup of non-stringy path components