def compile_subscriptions(node, event_type, event=None, level=0):
 subscriptions = check_node(node, event_type)
 if event:
  subscriptions = check_node(node, event)
  parent_subscriptions = compile_subscriptions(node, event_type, level=(level + 1))
 elif node.parent_id:
  parent_subscriptions = compile_subscriptions(AbstractNode.load(node.parent_id), event_type, level=(level + 1))
 else:
  parent_subscriptions = check_node(None, event_type)
 for notification_type in parent_subscriptions:
  p_sub_n = parent_subscriptions[notification_type]
  p_sub_n.extend(subscriptions[notification_type])
  for nt in subscriptions:
   if (notification_type != nt):
    p_sub_n = list(set(p_sub_n).difference(set(subscriptions[nt])))
  if (level == 0):
   (p_sub_n, removed) = utils.separate_users(node, p_sub_n)
  parent_subscriptions[notification_type] = p_sub_n
 return parent_subscriptions

def compile_subscriptions ( node , event_type , event = None , level = 0 ) : subscriptions = check_node ( node , event_type ) if event : subscriptions = check_node ( node , event ) parent_subscriptions = compile_subscriptions ( node , event_type , level = ( level + 1 ) ) elif node . parent_id : parent_subscriptions = compile_subscriptions ( AbstractNode . load ( node . parent_id ) , event_type , level = ( level + 1 ) ) else : parent_subscriptions = check_node ( None , event_type ) for notification_type in parent_subscriptions : p_sub_n = parent_subscriptions [ notification_type ] p_sub_n . extend ( subscriptions [ notification_type ] ) for nt in subscriptions : if ( notification_type != nt ) : p_sub_n = list ( set ( p_sub_n ) . difference ( set ( subscriptions [ nt ] ) ) ) if ( level == 0 ) : ( p_sub_n , removed ) = utils . separate_users ( node , p_sub_n ) parent_subscriptions [ notification_type ] = p_sub_n return parent_subscriptions
recurse through node and parents for subscriptions .