public static function locateExternalContainer()
    {
        // Get container from global var $app;
        // a Slim\App\Container or something similar.
        if (!empty($GLOBALS['app'])) {
            /** @var \Slim\App $app */
            $app = $GLOBALS['app'];
            if (method_exists($app, 'getContainer')) {
                /** @var \Psr\Container\ContainerInterface $container */
                $container = $app->getContainer();
                if ($container instanceof ContainerInterface) {
                    return $container;
                }
            }
        }
        return null;
    }