public function get_parent_context() {
        if (empty($this->_path) or $this->_id == SYSCONTEXTID) {
            return false;
        }

        $parentcontexts = trim($this->_path, '/'); // kill leading slash
        $parentcontexts = explode('/', $parentcontexts);
        array_pop($parentcontexts); // self
        $contextid = array_pop($parentcontexts); // immediate parent

        return context::instance_by_id($contextid, MUST_EXIST);
    }