You can use the following to avoid also processing when you get None
data = someXMLConverter(xml)
if hasattr(data, 'Items'):
if hasattr(data.Items, 'Item') and data.Items.Item is not None:
#some processing here
else:
return 'Error'
else:
return 'Error'
Since the if statement is short-circuited if hasattr
returns False
we can safely check for None
right after.