def gaze_duration(interest_area, fixation_sequence):
    """

    Given an interest area and fixation sequence, return the gaze duration on
    that interest area. Gaze duration is the sum duration of all fixations
    inside an interest area until the area is exited for the first time.

    """
    duration = 0
    for fixation in fixation_sequence.iter_without_discards():
        if fixation in interest_area:
            duration += fixation.duration
        elif duration > 0:
            break  # at least one previous fixation was inside the IA and this fixation is not, so break
    return duration