def _freeze_dict(dct):
    """Tries to freeze a dict to make it hashable."""
    result = []
    for key, value in dct.items():
        if isinstance(value, dict):
            value = _freeze_dict(value)
        result.append((key, value))
    result.sort()
    return tuple(result)