'Randomly choose a portgroup from list of portgroups.
:param element: the parent element
:returns: the randomly chosen port group'

@staticmethod
def _get_random_portgroup(element):

    portgroupelements = element.getElementsByTagName('PortGroup')
    if (portgroupelements and (len(portgroupelements) > 0)):
        portgroupnames = [portgroupelement.childNodes[0].nodeValue.strip() for portgroupelement in portgroupelements if portgroupelement.childNodes]
        portgroupnames = list(set(filter(None, portgroupnames)))
        pg_len = len(portgroupnames)
        if (pg_len > 0):
            return portgroupnames[random.randint(0, (pg_len - 1))]
    return None
