You can also get slug from direct post parent id like:
$parent_id = $post->post_parent;
$post_parent_slug = get_post_field( 'post_name', $parent_id );
Now you can replace:
'2' == $post->post_parent
to
'notes' == $post_parent_slug
Try this.