/// <summary>
        ///   The equals.
        /// </summary>
        /// <param name="other"> The other. </param>
        /// <returns> The System.Boolean. </returns>
        public bool Equals(SubTreeReference other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }

            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return(base.Equals(other) && Equals(other.SubTreeName, this.SubTreeName));
        }
        /// <summary>
        ///   The equals.
        /// </summary>
        /// <param name="other"> The other. </param>
        /// <returns> The System.Boolean. </returns>
        public bool Equals(SubTreeReference other)
        {
            if (ReferenceEquals(null, other))
            {
                return false;
            }

            if (ReferenceEquals(this, other))
            {
                return true;
            }

            return base.Equals(other) && Equals(other.SubTreeName, this.SubTreeName);
        }
        /// <summary>
        ///   Solves a sub tree reference by searching for the tree with the name specified in the reference. Also encapsulates the tree if necessary (e.g. because a blackboard is provided).
        /// </summary>
        /// <param name="subTreeReference"> Reference to resolve. </param>
        /// <returns> Task to use instead of the reference. </returns>
        private ITask SolveReference(SubTreeReference subTreeReference)
        {
            // Find tree reference.
            ITask treeReference = this.Get(subTreeReference.SubTreeName);
            if (treeReference == null && !string.IsNullOrEmpty(subTreeReference.SubTreeName))
            {
                throw new Exception(
                    string.Format(
                        "No tree reference found for tree named '{0}' in sub tree reference task.",
                        subTreeReference.SubTreeName));
            }

            // Encapsulate with CreateBlackboard task if blackboard is set.
            if (subTreeReference.Blackboard != null)
            {
                treeReference = new CreateBlackboard { Task = treeReference, Blackboard = subTreeReference.Blackboard };
            }

            return treeReference;
        }