code: def __find_sync_range(self, messages, preamble_end: int, search_end: int):
          
  
          possible_sync_pos = defaultdict(int)
  
  
          for i, msg in enumerate(messages):
              bits_i = msg.decoded_bits[preamble_end:search_end]
              for j in range(i, len(messages)):
                  bits_j = messages[j].decoded_bits[preamble_end:search_end]
                  first_diff = next((k for k, (bit_i, bit_j) in enumerate(zip(bits_i, bits_j)) if bit_i != bit_j), None)
                  if first_diff is not None:
                      first_diff = preamble_end + 4 * (first_diff // 4)
                      if (first_diff - preamble_end) >= 4:
                          possible_sync_pos[(preamble_end, first_diff)] += 1
          try:
              sync_interval = max(possible_sync_pos, key=possible_sync_pos.__getitem__)
              return sync_interval
          except ValueError:
              return None
docs: Finding the synchronization works by finding the first difference between two messages.
          This is performed for all messages and the most frequent first difference is chosen
  
          :type messages: list of Message
          :param preamble_end: End of preamble = start of search
          :param search_end: End of search = start of first other label