def j_map_to_dict(m):
    """Converts a java map to a python dictionary."""
    if not m:
        return None

    r = {}
    for e in m.entrySet().toArray():
        k = e.getKey()
        v = e.getValue()
        r[k] = v

    return r