Helper method to create a <Style/> element in a KML document.

    Args:
      doc: the parent KML document.
      style_id: the style id to include for the <Style/> element.
      style_dict: a dict of sub-elements and values to add to the <Style/>.

    Returns:
      The newly created <Style/> element.

    Each key of the style_dict argument is used to create a sub-element of the
    parent <Style/> element.  If the value associated with that key is a string,
    then it will be used to set the text value of the sub-element.  If the value
    is another dict, it will be used to recursively construct a sub-sub-element
    with the same semantics.

def _CreateStyle(self, doc, style_id, style_dict):
    """Helper method to create a <Style/> element in a KML document.

    Args:
      doc: the parent KML document.
      style_id: the style id to include for the <Style/> element.
      style_dict: a dict of sub-elements and values to add to the <Style/>.

    Returns:
      The newly created <Style/> element.

    Each key of the style_dict argument is used to create a sub-element of the
    parent <Style/> element.  If the value associated with that key is a string,
    then it will be used to set the text value of the sub-element.  If the value
    is another dict, it will be used to recursively construct a sub-sub-element
    with the same semantics.
    """

    def CreateElements(current_element, current_dict):
      for (key, value) in current_dict.iteritems():
        element = ET.SubElement(current_element, key)
        if isinstance(value,dict):
          CreateElements(element, value)
        else:
          element.text = value

    style = ET.SubElement(doc, 'Style', {'id': style_id})
    CreateElements(style, style_dict)
    return style