def get_parent_notification_type(node, event, user):
 AbstractNode = apps.get_model('osf.AbstractNode')
 NotificationSubscription = apps.get_model('osf.NotificationSubscription')
 if (node and isinstance(node, AbstractNode) and node.parent_node and node.parent_node.has_permission(user, 'read')):
  parent = node.parent_node
  key = to_subscription_key(parent._id, event)
  try:
   subscription = NotificationSubscription.find_one(Q('_id', 'eq', key))
  except NoResultsFound:
   return get_parent_notification_type(parent, event, user)
  for notification_type in constants.NOTIFICATION_TYPES:
   if getattr(subscription, notification_type).filter(id=user.id).exists():
    return notification_type
  else:
   return get_parent_notification_type(parent, event, user)
 else:
  return None

def get_parent_notification_type ( node , event , user ) : AbstractNode = apps . get_model ( 'osf.AbstractNode' ) NotificationSubscription = apps . get_model ( 'osf.NotificationSubscription' ) if ( node and isinstance ( node , AbstractNode ) and node . parent_node and node . parent_node . has_permission ( user , 'read' ) ) : parent = node . parent_node key = to_subscription_key ( parent . _id , event ) try : subscription = NotificationSubscription . find_one ( Q ( '_id' , 'eq' , key ) ) except NoResultsFound : return get_parent_notification_type ( parent , event , user ) for notification_type in constants . NOTIFICATION_TYPES : if getattr ( subscription , notification_type ) . filter ( id = user . id ) . exists ( ) : return notification_type else : return get_parent_notification_type ( parent , event , user ) else : return None
given an event on a node .