/**
  * Will insert a structure definition into our hierarchy
  *
  * @param \TechDivision\PBC\Interfaces\StructureDefinitionInterface $node The structure definition to insert
  *
  * @return bool
  */
 public function insert(StructureDefinitionInterface $node)
 {
     // Already here? Nothing to do then
     $qualifiedName = $node->getQualifiedName();
     if (!empty($this->nodes[$qualifiedName])) {
         return true;
     }
     // Add the node
     $this->nodes[$qualifiedName] = $node;
     // Add empty entries for the dependencies so we can check if all where added
     $dependencies = $node->getDependencies();
     foreach ($dependencies as $dependency) {
         if (!empty($this->nodes[$dependency])) {
             continue;
         } else {
             $this->nodes[$dependency] = null;
         }
     }
     // Still here? Sounds great
     return true;
 }
 /**
  * Will check if a certain structure was mentioned in one(!) use statement.
  *
  * @param StructureDefinitionInterface $structureDefinition The structure $structureName is compared against
  * @param string                       $structureName       The name of the structure we have to check against the
  *                                                          use statements of the definition
  *
  * @return bool|string
  */
 protected function resolveUsedNamespace(StructureDefinitionInterface &$structureDefinition, $structureName)
 {
     // If there was no useful name passed we can fail right here
     if (empty($structureName)) {
         return false;
     }
     // Walk over all namespaces and if we find something we will act accordingly.
     $result = $structureDefinition->getQualifiedName();
     foreach ($structureDefinition->getUsedNamespaces() as $key => $usedNamespace) {
         // Check if the last part of the use statement is our structure
         $tmp = explode('\\', $usedNamespace);
         if (array_pop($tmp) === $structureName) {
             // Tell them we succeeded
             return trim(implode('\\', $tmp) . '\\' . $structureName, '\\');
         }
     }
     // We did not seem to have found anything. Might it be that we are in our own namespace?
     if ($structureDefinition->getNamespace() !== null && strpos($structureName, '\\') !== 0) {
         return $structureDefinition->getNamespace() . '\\' . $structureName;
     }
     // Still here? Return what we got.
     return $result;
 }