public List<ExpressionLeaf> GetLeafNodes(AExpression parent = null)
 {
     var result = new List<ExpressionLeaf>();
     Parent = parent;
     GetLeafNode(Left, ref result);
     GetLeafNode(Right, ref result);
     return result;
 }
 private void GetLeafNode(AExpression expr,  ref List<ExpressionLeaf> result)
 {
     var exprLeaf = expr as ExpressionLeaf;
     if (exprLeaf == null)
     {
         result.AddRange(expr.GetLeafNodes(this));
     }
     else 
     {
         result.Add(exprLeaf);
     }
 }
 public AExpression(BaseKnowledge left, string op, BaseKnowledge right)
 {
     if (left != null)
     {
         var l = left as AExpression;
         Left = l ?? new ExpressionLeaf(left);
     }
     Operator = op;
     if (right != null)
     {
         var r = right as AExpression;
         Right = r ?? new ExpressionLeaf(right);
     }
 }