public function getRecord($id, $versionID = null)
    {
        if (!$id) {
            return null;
        }
        $treeClass = $this->config()->get('tree_class');
        if ($id instanceof $treeClass) {
            return $id;
        }
        if (substr($id, 0, 3) == 'new') {
            return $this->getNewItem($id);
        }
        if (!is_numeric($id)) {
            return null;
        }

        $currentStage = Versioned::get_reading_mode();

        if ($this->getRequest()->getVar('Version')) {
            $versionID = (int) $this->getRequest()->getVar('Version');
        }

        /** @var SiteTree $record */
        if ($versionID) {
            $record = Versioned::get_version($treeClass, $id, $versionID);
        } else {
            $record = DataObject::get_by_id($treeClass, $id);
        }

        // Then, try getting a record from the live site
        if (!$record) {
            // $record = Versioned::get_one_by_stage($treeClass, "Live", "\"$treeClass\".\"ID\" = $id");
            Versioned::set_stage(Versioned::LIVE);
            singleton($treeClass)->flushCache();

            $record = DataObject::get_by_id($treeClass, $id);
        }

        // Then, try getting a deleted record
        if (!$record) {
            $record = Versioned::get_latest_version($treeClass, $id);
        }

        // Set the reading mode back to what it was.
        Versioned::set_reading_mode($currentStage);

        return $record;
    }