docs: def _add_potential(self, potential, parent_tag):
          """
          Adds Potentials to the ProbModelXML.
  
          Parameters
          ----------
          potential: dict
              Dictionary containing Potential data.
              For example: {'role': 'Utility',
                            'Variables': ['D0', 'D1', 'C0', 'C1'],
                            'type': 'Tree/ADD',
                            'UtilityVaribale': 'U1'}
          parent_tag: etree Element
              etree element which would contain potential tag
              For example: <Element Potentials at 0x7f315fc44b08>
                           <Element Branch at 0x7f315fc44c88>
                           <Element Branch at 0x7f315fc44d88>
                           <Element Subpotentials at 0x7f315fc44e48>
  
          Examples
          --------
          >>> writer = ProbModelXMLWriter(model)
          >>> writer._add_potential(potential, parent_tag)
          """
          potential_type = potential['type']
          try:
              potential_tag = etree.SubElement(parent_tag, 'Potential', attrib={
                  'type': potential['type'], 'role': potential['role']})
          except KeyError:
              potential_tag = etree.SubElement(parent_tag, 'Potential', attrib={
                  'type': potential['type']})
          self._add_element(potential, 'Comment', potential_tag)
          if 'AdditionalProperties' in potential:
              self._add_additional_properties(potential_tag, potential['AdditionalProperties'])
          if potential_type == "delta":
              etree.SubElement(potential_tag, 'Variable', attrib={'name': potential['Variable']})
              self._add_element(potential, 'State', potential_tag)
              self._add_element(potential, 'StateIndex', potential_tag)
              self._add_element(potential, 'NumericValue', potential_tag)
          else:
              if 'UtilityVariable' in potential:
                  etree.SubElement(potential_tag, 'UtilityVariable', attrib={
                      'name': potential['UtilityVariable']})
              if 'Variables' in potential:
                  variable_tag = etree.SubElement(potential_tag, 'Variables')
                  for var in sorted(potential['Variables']):
                      etree.SubElement(variable_tag, 'Variable', attrib={'name': var})
                      for child in sorted(potential['Variables'][var]):
                          etree.SubElement(variable_tag, 'Variable', attrib={'name': child})
              self._add_element(potential, 'Values', potential_tag)
              if 'UncertainValues' in potential:
                  value_tag = etree.SubElement(potential_tag, 'UncertainValues', attrib={})
                  for value in sorted(potential['UncertainValues']):
                      try:
                          etree.SubElement(value_tag, 'Value', attrib={
                              'distribution': value['distribution'],
                              'name': value['name']}).text = value['value']
                      except KeyError:
                          etree.SubElement(value_tag, 'Value', attrib={
                              'distribution': value['distribution']}).text = value['value']
              if 'TopVariable' in potential:
                  etree.SubElement(potential_tag, 'TopVariable', attrib={'name': potential['TopVariable']})
              if 'Branches' in potential:
                  branches_tag = etree.SubElement(potential_tag, 'Branches')
                  for branch in potential['Branches']:
                      branch_tag = etree.SubElement(branches_tag, 'Branch')
                      if 'States' in branch:
                          states_tag = etree.SubElement(branch_tag, 'States')
                          for state in sorted(branch['States']):
                              etree.SubElement(states_tag, 'State', attrib={'name': state['name']})
                      if 'Potential' in branch:
                          self._add_potential(branch['Potential'], branch_tag)
                      self._add_element(potential, 'Label', potential_tag)
                      self._add_element(potential, 'Reference', potential_tag)
                      if 'Thresholds' in branch:
                          thresholds_tag = etree.SubElement(branch_tag, 'Thresholds')
                          for threshold in branch['Thresholds']:
                              try:
                                  etree.SubElement(thresholds_tag, 'Threshold', attrib={
                                      'value': threshold['value'], 'belongsTo': threshold['belongsTo']})
                              except KeyError:
                                  etree.SubElement(thresholds_tag, 'Threshold', attrib={
                                      'value': threshold['value']})
              self._add_element(potential, 'Model', potential_tag)
              self._add_element(potential, 'Coefficients', potential_tag)
              self._add_element(potential, 'CovarianceMatrix', potential_tag)
              if 'Subpotentials' in potential:
                  subpotentials = etree.SubElement(potential_tag, 'Subpotentials')
                  for subpotential in potential['Subpotentials']:
                      self._add_potential(subpotential, subpotentials)
              if 'Potential' in potential:
                  self._add_potential(potential['Potential'], potential_tag)
              if 'NumericVariables' in potential:
                  numvar_tag = etree.SubElement(potential_tag, 'NumericVariables')
                  for var in sorted(potential['NumericVariables']):
                      etree.SubElement(numvar_tag, 'Variable', attrib={'name': var})