Are you talking about XML::TreePP? You can use ref to check the return type: if it's an array, OK; if it's a hash, put it into an array; continue processing.
You may want to contact the author to see if this could be handled better in the module, or perhaps there is reason behind the behavior.