def longest_sequence(msa):
    """
    Returns the longest sequence in the provided MultipleSequenceAlignment
    object.
    """
    longest = None
    for sequence in msa.sequences:
        if not longest or longest < len(sequence.ungapped()):
            longest = len(sequence.ungapped())
    return longest
