def difflist(lista, listb, indentlevel):
    retstr = ''
    addedlist = []
    deletedlist = []

    for item in lista:
        if item in listb:
            brackets = charfortype(item)
            if type(item) is str or type(item) is unicode:
                retstr += same("{3}{1}{0}{2},".format(escape(item), brackets[0], brackets[1], i(indentlevel)))
            else:
                # Handle lists and dicts here:
                diffstr = ''
                if type(item) is list or type(item) is dict:
                    diffstr = printsomething(item, 'same', indentlevel+1)
                retstr += same("{3}{1}<br/>\n{0}{3}{2},".format(diffstr, brackets[0], brackets[1], i(indentlevel)))
        else:
            addedlist.append(item)
    for item in listb:
        if not item in lista:
            deletedlist.append(item)
    for item in addedlist:
        bestmatch = findmostsimilar(item, deletedlist)
        brackets = charfortype(item)
        if None is bestmatch:
            if type(item) is str or type(item) is unicode:
                retstr += added("{3}{1}{0}{2},".format(escape(item), brackets[0], brackets[1], i(indentlevel)))
            else:
                # Handle lists and dicts here:
                diffstr = ''
                if type(item) is list or type(item) is dict:
                    diffstr = printsomething(item, 'added', indentlevel+1)
                retstr += added("{3}{1}<br/>\n{0}{3}{2},".format(diffstr, brackets[0], brackets[1], i(indentlevel)))
        else:
            if type(item) is str or type(item) is unicode:
                retstr += deleted("{3}{1}{0}{2},".format(escape(bestmatch), brackets[0], brackets[1], i(indentlevel)))
                retstr += added("{3}{1}{0}{2},".format(escape(item), brackets[0], brackets[1], i(indentlevel)))
            else:
                # Handle lists and dicts here:
                diffstr = ''
                if type(item) is list:
                    diffstr = difflist(item, bestmatch, indentlevel+1)
                elif type(item) is dict:
                    diffstr = diffdict(item, bestmatch, indentlevel+1)
                retstr += same("{3}{1}<br/>\n{0}{3}{2},".format(diffstr, brackets[0], brackets[1], i(indentlevel)))
            deletedlist.remove(bestmatch)
    for item in deletedlist:
        brackets = charfortype(item)
        if type(item) is str or type(item) is unicode:
            retstr += deleted("{3}{1}{0}{2},".format(escape(item), brackets[0], brackets[1], i(indentlevel)))
        else:
            # Handle lists and dicts here:
            diffstr = ''
            if type(item) is list or type(item) is dict:
                diffstr = printsomething(item, 'deleted', indentlevel+1)
            retstr += deleted("{3}{1}<br/>\n{0}{3}{2},".format(diffstr, brackets[0], brackets[1], i(indentlevel)))
    return remove_last_comma(retstr)


# levenshtein - http://hetland.org/coding/python/levenshtein.py
diffdict and difflist are recursive methods which build an HTML representation of the differences between two objects.
dataset/ETHPy150Open Netflix/security_monkey/security_monkey/common/PolicyDiff.py/difflist