private void RecursiveComputePositions(ModelTask t)
 {
     for (int i = 0; i < t.children.Count; ++i) {
         ModelTask currentChild = t.children[i];
         Position currentChildPos = new Position(t.position);
         currentChildPos.AddMove(i);
         currentChild.position = currentChildPos;
         RecursiveComputePositions(currentChild);
     }
 }
        /// <summary>
        /// This method computes the positions of all the tasks of the behaviour tree
        /// whose root is this node. After calling this method, the positions of all
        /// the tasks below this one will be available and accessible through
        /// {@link #getPosition()}.
        ///
        /// It is important to note that, when calling this method, this task is
        /// considered to be the root of the behaviour tree, so its position will be
        /// set to an empty sequence of moves, with no offset, and the positions of
        /// the tasks below it will be computed from it.
        /// </summary>
        public void ComputePositions()
        {
            // assume this node is the root of the tree
            this.position = new Position(new LinkedList<int>());

            /*
             * Set the position of all of the children of this task and recursively
             * compute the position of the rest of the tasks.
             */
            for (int i = 0; i < this.children.Count; ++i) {
                ModelTask currentChild = this.children[i];
                Position currentChildPos = new Position(this.position);
                currentChildPos.AddMove(i);
                currentChild.position = currentChildPos;
                RecursiveComputePositions(currentChild);
            }
        }