Fix bug: Need to check if the parent is in the $reference_courses array before we attempt to access it.