docs: def _GetUnsortedNotifications(self,
                                  queue_shard,
                                  notifications_by_session_id=None):
      """Returns all the available notifications for a queue_shard.
  
      Args:
        queue_shard: urn of queue shard
        notifications_by_session_id: store notifications in this dict rather than
          creating a new one
  
      Returns:
        dict of notifications. keys are session ids.
      """
      if notifications_by_session_id is None:
        notifications_by_session_id = {}
      end_time = self.frozen_timestamp or rdfvalue.RDFDatetime.Now()
      for notification in self.data_store.GetNotifications(queue_shard, end_time):
  
        existing = notifications_by_session_id.get(notification.session_id)
        if existing:
          # If we have a notification for this session_id already, we only store
          # the one that was scheduled last.
          if notification.first_queued > existing.first_queued:
            notifications_by_session_id[notification.session_id] = notification
          elif notification.first_queued == existing.first_queued and (
              notification.last_status > existing.last_status):
            # Multiple notifications with the same timestamp should not happen.
            # We can still do the correct thing and use the latest one.
            logging.warning(
                "Notifications with equal first_queued fields detected: %s %s",
                notification, existing)
            notifications_by_session_id[notification.session_id] = notification
        else:
          notifications_by_session_id[notification.session_id] = notification
  
      return notifications_by_session_id