def find_pair_by_segment_name(pairs, segment_name):
    """Given a segment name (for example p3) return the matching pair structue. """
            #find the pair name
    for n_pair, pair in enumerate(pairs):
        if segment_name in pair['pair']:
            return pair