Class representing actual chain.
Inheritance: ICloneable
 /// <summary>
 /// The clone.
 /// </summary>
 /// <returns>
 /// The <see cref="object"/>.
 /// </returns>
 public object Clone()
 {
     var clone = new ActualChain((BaseChain)Source.Clone())
         {
             resultChain = (BaseChain)resultChain.Clone(),
             actualLength = actualLength
         };
     return clone;
 }
        /// <summary>
        /// The divide.
        /// </summary>
        /// <param name="chain">
        /// The chain.
        /// </param>
        /// <returns>
        /// The <see cref="BaseChain"/>.
        /// </returns>
        public BaseChain Divide(BaseChain chain)
        {
            var firstChain = new ActualChain(chain);
            var stack = new Stack();
            stack.Push(firstChain);
            ArrayList list = alphabet.GetLengthList();
            do
            {
                var actChain = (ActualChain)stack.Pop();
                BaseChain chain4Check = actChain.Source;

                for (int i = list.Count - 1; i >= 0; i--)
                {
                    BaseChain word;
                    if (chain4Check.GetLength() >= (int)list[i])
                    {
                        var it = new IteratorStart(chain4Check, (int)list[i], 1);
                        it.Next();
                        word = (BaseChain)it.Current();
                    }
                    else
                    {
                        continue;
                    }

                    if (alphabet.Contains(word))
                    {
                        // solution is found
                        if (chain4Check.GetLength() == (int)list[i])
                        {
                            actChain.RemoveCharacter((int)list[i]);
                            return actChain.GetResult();
                        }

                        var newChain = (ActualChain)actChain.Clone();
                        newChain.RemoveCharacter((int)list[i]);
                        stack.Push(newChain);
                    }
                }
            }
            while (stack.Count > 0);
            return null;
        }