public function findQualifiedName($class, $type, $namespace = null)
    {
        // Check if we already resolved that name
        if (array_key_exists($class, $this->lookedUp)) {
            return $this->lookedUp[$type][$class];
        }

        $paths = $this->getLookups($type);
        $paths[] = '%s';

        // Create classes array
        $class = ucfirst($class);
        $classes = $namespace ? [ucfirst($namespace).'\\'.$class, $class] : [$class];

        // Search for first existing class
        $qualified = false;
        foreach ($classes as $class) {
            foreach ($paths as $path) {
                $path = sprintf($path, $class);
                if (class_exists($path)) {
                    $qualified = $path;
                    break 2;
                }
            }
        }

        return $this->lookedUp[$type][$class] = $qualified;
    }