def _guess_main_sequence(madx):
    """Try to guess the 'main' sequence to be viewed."""
    sequence = madx.sequence()
    if sequence:
        return sequence.name
    sequences = madx.sequence
    if not sequences:
        raise ValueError('No sequences defined!')
    if len(sequences) != 1:
        raise ValueError(
            'Multiple sequences defined, none active. Cannot uniquely determine which to use.'
            )
    return next(iter(sequences))
