def get_keyframe_range(obj):
    """
    Returns minimal and maximal frame number of the animation associated with
    the object.
    """
    anim = obj.animation_data
    if not anim or not anim.action:
        return [0, 0]
    res = None
    for fcu in anim.action.fcurves:
        for keyframe in fcu.keyframe_points:
            t = keyframe.co[0]
            if res is None:
                res = [t, t]
            else:
                if t < res[0]:
                    res[0] = t
                if t > res[1]:
                    res[1] = t
    return res