public function getPackage()
    {
        $inheritedElement = $this->getInheritedElement();
        if ($this->package instanceof PackageDescriptor
            && ! ($this->package->getName() === '\\' && $inheritedElement)) {
            return $this->package;
        }

        if ($inheritedElement instanceof DescriptorAbstract) {
            return $inheritedElement->getPackage();
        }

        return null;
    }