private BaseNode GetHighestPemdas()
{
Debug.Assert(null != Next);
BaseNode RootNode = this;
for (BaseNode iter = Next; iter != null; iter = iter.Next)
{
//if we found a subtraction node, that is the highest value
if (PemdasValue.Subtraction == RootNode.OrderOfOperationsValue)
{
break;
}
else if (iter.OrderOfOperationsValue > RootNode.OrderOfOperationsValue)
{
//The next node has a higher value than the current champion
RootNode = iter;
}
}
//ok, return the node we found with the highest value.
return RootNode;
}