Python algorithm that converts an XML file into JSON