/**
  * @return Template
  */
 public function loadTemplateWithElementNamespaceOrPackage(Template $template, ReflectionElement $element)
 {
     if ($namespaces = $this->elementStorage->getNamespaces()) {
         $name = $element->getPseudoNamespaceName();
         $template = $this->loadTemplateWithNamespace($template, $name, $namespaces[$name]);
     } elseif ($packages = $this->elementStorage->getPackages()) {
         $name = $element->getPseudoPackageName();
         $template = $this->loadTemplateWithNamespace($template, $name, $packages[$name]);
     }
     return $template;
 }
 /**
  * @param string $elementName
  * @param string $elementType
  * @param ReflectionElement|ReflectionClass $element
  */
 private function categorizeElementToNamespaceAndPackage($elementName, $elementType, ReflectionElement $element)
 {
     $packageName = $element->getPseudoPackageName();
     $this->packages[$packageName][$elementType][$elementName] = $element;
     $namespaceName = $element->getPseudoNamespaceName();
     $this->namespaces[$namespaceName][$elementType][$element->getShortName()] = $element;
 }