def group_by_node(notifications):
 emails = NotificationsDict()
 for notification in notifications:
  emails.add_message(notification['node_lineage'], notification['message'])
 return emails

def group_by_node ( notifications ) : emails = NotificationsDict ( ) for notification in notifications : emails . add_message ( notification [ 'node_lineage' ] , notification [ 'message' ] ) return emails
take list of notifications and group by node .