private function prepareTreeSelector(PickerInterface $picker)
    {
        $modelId = ModelId::fromSerialized($picker->getConfig()->getExtra('modelId'));

        if (Validator::isInsecurePath($table = $modelId->getDataProviderName())) {
            throw new \InvalidArgumentException('The table name contains invalid characters');
        }

        if (Validator::isInsecurePath($field = $picker->getConfig()->getExtra('propertyName'))) {
            throw new \InvalidArgumentException('The field name contains invalid characters');
        }

        $sessionBag = $this->container->get('session')->getBag('contao_backend');
        // Define the current ID.
        \define('CURRENT_ID', ($table ? $sessionBag->get('CURRENT_ID') : $modelId->getId()));

        $this->itemContainer = (new DcGeneralFactory())
            ->setContainerName($modelId->getDataProviderName())
            ->setTranslator($this->container->get('cca.translator.contao_translator'))
            ->setEventDispatcher($this->container->get('event_dispatcher'))
            ->createDcGeneral();

        // Merge with the information from the data container.
        $property = $this
            ->itemContainer
            ->getEnvironment()
            ->getDataDefinition()
            ->getPropertiesDefinition()
            ->getProperty($picker->getConfig()->getExtra('propertyName'));

        $information = (array) $GLOBALS['TL_DCA'][$table]['fields'][$field];
        if (!isset($information['eval'])) {
            $information['eval'] = array();
        }
        $information['eval'] = array_merge($property->getExtra(), $information['eval']);

        $treeSelector = new $GLOBALS['BE_FFL']['DcGeneralTreePicker'](
            Widget::getAttributesFromDca(
                $information,
                $field,
                \array_filter(\explode(',', $picker->getConfig()->getValue())),
                $field,
                $table,
                new DcCompat($this->itemContainer->getEnvironment())
            ),
            new DcCompat($this->itemContainer->getEnvironment())
        );

        $treeSelector->id = 'tl_listing';

        return $treeSelector;
    }