'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.'

def _GetUnsortedNotifications(self, queue_shard, notifications_by_session_id=None):

    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, token=self.token):
        existing = notifications_by_session_id.get(notification.session_id)
        if existing:
            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)):
                logging.warn('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
