private function get_course_categories() {
        global $CFG;
        require_once($CFG->dirroot.'/course/lib.php');

        $categories = array();
        $cap = 'moodle/category:viewhiddencategories';
        $showcategories = !core_course_category::is_simple_site();

        if ($showcategories) {
            foreach ($this->page->categories as $category) {
                $context = context_coursecat::instance($category->id);
                if (!core_course_category::can_view_category($category)) {
                    continue;
                }
                $url = new moodle_url('/course/index.php', array('categoryid' => $category->id));
                $name = format_string($category->name, true, array('context' => $context));
                $categorynode = breadcrumb_navigation_node::create($name, $url, self::TYPE_CATEGORY, null, $category->id);
                if (!$category->visible) {
                    $categorynode->hidden = true;
                }
                $categories[] = $categorynode;
            }
        }

        // Don't show the 'course' node if enrolled in this course.
        if (!is_enrolled(context_course::instance($this->page->course->id, null, '', true))) {
            $courses = $this->page->navigation->get('courses');
            if (!$courses) {
                // Courses node may not be present.
                $courses = breadcrumb_navigation_node::create(
                    get_string('courses'),
                    new moodle_url('/course/index.php'),
                    self::TYPE_CONTAINER
                );
            }
            $categories[] = $courses;
        }

        return $categories;
    }