Firstly, I'd strongly suggest breaking apart the convert_xml_to_json function into smaller, more manageable chunks. It's currently doing way too much. There's also quite a lot of code duplicated between if and else branches that could be extracted into separate functions. Lots of copy-pasted code is a bit of a maintenance headache because a) it makes the code harder to read and reason about and b) it's easy to fix a bug in one part of the code and forget to update all the other copy-pasted versions of it.
Originally posted by @alexdewar in #263 (review)