@staticmethod
def flatten(l):
    """
        from http://rightfootin.blogspot.com/2006/09/more-on-python-flatten.html
        :param l:
        :return:
        """
    list_type = type(l)
    l = list(l)
    i = 0
    while i < len(l):
        while isinstance(l[i], list):
            if not l[i]:
                l.pop(i)
                i -= 1
                break
            else:
                l[i:i + 1] = l[i]
        i += 1
    return list_type(l)
