/// <summary>Returns pair of (depth,breadth) of tree.</summary>
        /// <remarks>Returns pair of (depth,breadth) of tree. Does a breadth-first search.</remarks>
        /// <param name="t"/>
        /// <param name="ocs"/>
        /// <param name="addToVocab"/>
        private static Pair <int, int> DissectTree(Tree t, TreebankStats.ObservedCorpusStats ocs, bool addToVocab)
        {
            Stack <Pair <int, Tree> > stack = new Stack <Pair <int, Tree> >();

            stack.Push(new Pair <int, Tree>(0, t));
            int maxBreadth = 0;
            int maxDepth   = -1;

            if (t == null)
            {
                throw new Exception("Null tree passed to dissectTree()");
            }
            else
            {
                while (!stack.IsEmpty())
                {
                    Pair <int, Tree> depthNode = stack.Pop();
                    int  nodeDepth             = depthNode.First();
                    Tree node = depthNode.Second();
                    if (nodeDepth != maxDepth)
                    {
                        maxDepth = nodeDepth;
                        if (node.IsPhrasal() && stack.Count + 1 > maxBreadth)
                        {
                            maxBreadth = stack.Count + 1;
                        }
                    }
                    if (node.IsPhrasal())
                    {
                        ocs.AddPhrasalBranch(node.Value(), node.Children().Length);
                    }
                    else
                    {
                        if (node.IsPreTerminal())
                        {
                            ocs.posTags.IncrementCount(node.Value());
                        }
                        else
                        {
                            if (node.IsLeaf())
                            {
                                ocs.words.IncrementCount(node.Value());
                                if (addToVocab)
                                {
                                    trainVocab.Add(node.Value());
                                }
                            }
                        }
                    }
                    foreach (Tree kid in node.Children())
                    {
                        stack.Push(new Pair <int, Tree>(nodeDepth + 1, kid));
                    }
                }
            }
            return(new Pair <int, int>(maxDepth, maxBreadth));
        }