code: private function buildTree(array $variations)
      {
          $this->detectCircularDependencies($variations);
          $dependent = [];
  
          foreach ($variations as $root) {
              foreach ($variations as $key => $nested) {
                  if ($nested->dependsOn($root->getName())) {
                      $dependent[] = $key;
                      $root->addNested($nested);
                  }
              }
          }
  
          foreach ($dependent as $key) {
              unset($variations[$key]);
          }
  
          return $variations;
      }
docs: @param AbstractVariation[] $variations
  
  @return AbstractVariation[]
  
  @throws Exception\CircularDependencyException