public void Split(int count)
        {
            Outputs.Clear();
            int smallestPower = Context.GetSmallestPower(count);

            SplitIntoPower(smallestPower);
            //do the merging
            List <Output> finals       = GetFinalOutputs();
            List <Output> outputsToAdd = new List <Output>();

            for (int i = 0; i < smallestPower - count; i++)
            {
                outputsToAdd.Add(finals[i]);
            }
            if (outputsToAdd.Count > 0)
            {
                Node   oldInput = Inputs[0];
                Merger merger   = (oldInput as ICanInsertMergerAfter).InsertMergerAfter();
                merger.AddInputsSafe(outputsToAdd);
                merger.OutputRate = oldInput.OutputRate + oldInput.OutputRate / count * (smallestPower - count);
            }
        }
 public void AddInputSafe(Output node)
 {
     if (Inputs.Count < Context.MergerInputs)
     {
         node.Inputs[0].ReassignOutput(node, this);
         Inputs.Add(node.Inputs[0]);
     }
     else
     {
         int    lowestDepth = int.MaxValue;
         Merger bestMerger  = null;
         foreach (Node input in Inputs)
         {
             if (input is Merger merger)
             {
                 int i = merger.AddInputSafeDepth();
                 if (i < lowestDepth)
                 {
                     lowestDepth = i;
                     bestMerger  = merger;
                 }
             }
         }
         if (bestMerger == null)
         {
             Node   temp   = Inputs[Context.MergerInputs - 1];
             Merger merger = new Merger(Context, this, temp);
             merger.AddInputSafe(temp, this);
             merger.AddInputSafe(node);
         }
         else
         {
             bestMerger.AddInputSafe(node);
         }
     }
 }