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;
    }
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;
    }
@param AbstractVariation[] $variations

@return AbstractVariation[]

@throws Exception\CircularDependencyException