private function doDetect($className, $performInterfaceDetection = true)
    {
        $detection = $this->doDetectByRoutes($className);
        if ($detection) {
            return $detection;
        }
        //Nothing is found so far. We will check all of the class interfaces and base classes.
        //First - check base classes up to the 'root'
        $parentClass = get_parent_class($className);
        if ($parentClass) {
            $parentDetection = $this->doDetect($parentClass, false);
            if ($parentDetection instanceof ClassDetection) {
                return $parentDetection;
            }
        }
        //Check the class interfaces
        if ($performInterfaceDetection) {
            $definition = $this->doDetectByInterfaces($className);
            if ($definition) {
                return $definition;
            }
        }

        return new DefaultDetection($this->defaultRoute);
    }