/// <summary>
        /// Creates a disjunction of the current conditions and the specified other conditions.
        /// </summary>
        /// <param name="other">Other conditions.</param>
        /// <returns>Disjunction of the current conditions and the given other conditions.</returns>
        public IConditions DisjunctionWith(IConditions other)
        {
            if (other is ConditionsContradiction)
            {
                return((IConditions)Clone());
            }

            ConditionsClause newClause = (ConditionsClause)Clone();

            ConditionsClause otherClause = other as ConditionsClause;

            if (otherClause != null)
            {
                foreach (var conditions in otherClause)
                {
                    newClause.Add((Conditions)conditions.Clone());
                }
            }
            else
            {
                Debug.Assert(other is Conditions);
                newClause.Add((Conditions)other.Clone());
            }

            return(newClause);
        }
        /// <summary>
        /// Makes a deep copy of the conditions.
        /// </summary>
        /// <returns>Deep copy of the conditions.</returns>
        public Planner.IConditions Clone()
        {
            ConditionsClause clause = new ConditionsClause();

            foreach (var conditions in this)
            {
                clause.Add((Conditions)conditions.Clone());
            }
            return(clause);
        }
        /// <summary>
        /// Checks the equality of objects.
        /// </summary>
        /// <param name="obj">Object to be checked.</param>
        /// <returns>True if the objects are equal, false otherwise.</returns>
        public override bool Equals(object obj)
        {
            if (obj == this)
            {
                return(true);
            }

            ConditionsClause other = obj as ConditionsClause;

            if (other == null)
            {
                return(false);
            }

            return(CollectionsEquality.Equals(this, other));
        }
        /// <summary>
        /// Creates a conjunction of the current conditions and the specified other conditions.
        /// </summary>
        /// <param name="other">Other conditions.</param>
        /// <returns>Conjunction of the current conditions and the given other conditions.</returns>
        public IConditions ConjunctionWith(IConditions other)
        {
            List <Conditions> newConditions = new List <Conditions>();

            foreach (var conditions in this)
            {
                if (!conditions.IsConflictedWith(other))
                {
                    IConditions conjunction = conditions.ConjunctionWith(other);

                    ConditionsClause clause = conjunction as ConditionsClause;
                    if (clause != null)
                    {
                        foreach (var innerConditions in clause)
                        {
                            newConditions.Add(innerConditions);
                        }
                    }
                    else
                    {
                        Conditions innerConditions = conjunction as Conditions;
                        if (innerConditions != null)
                        {
                            newConditions.Add(innerConditions);
                        }
                    }
                }
            }

            switch (newConditions.Count)
            {
            case 0:
                return(new ConditionsContradiction());

            case 1:
                return(newConditions[0]);

            default:
                return(new ConditionsClause(newConditions.ToArray()));
            }
        }