/// <summary>
        /// Applies layout changes to a given box and its children.
        /// </summary>
        public override void ApplyVerticalLayout([NotNull] LayoutState state, [NotNull] LayoutState.LayoutLevel level)
        {
            var node = level.BranchRoot;

            if (node.Level == 0)
            {
                node.State.SiblingsRowV = new Dimensions(
                    node.State.Top,
                    node.State.Bottom);
            }

            if (node.State.NumberOfSiblings == 0)
            {
                return;
            }

            var siblingsRowExterior = Dimensions.MinMax();

            if (Orientation == StackOrientation.SingleRowHorizontal)
            {
                var top = node.AssistantsRoot == null
                    ? node.State.SiblingsRowV.To + ParentChildSpacing
                    : node.State.BranchExterior.Bottom + ParentChildSpacing;

                for (var i = 0; i < node.State.NumberOfSiblings; i++)
                {
                    var child = node.Children[i];
                    var rect  = child.State;

                    child.State.MoveTo(0, top);
                    child.State.BranchExterior = new Rect(child.State.TopLeft, child.State.Size);

                    siblingsRowExterior += new Dimensions(top, top + rect.Size.Height);
                }

                siblingsRowExterior = new Dimensions(siblingsRowExterior.From, siblingsRowExterior.To);

                for (var i = 0; i < node.State.NumberOfSiblings; i++)
                {
                    var child = node.Children[i];
                    child.State.SiblingsRowV = siblingsRowExterior;

                    // re-enter layout algorithm for child branch
                    LayoutAlgorithm.VerticalLayout(state, child);
                }
            }
            else if (Orientation == StackOrientation.SingleColumnVertical)
            {
                var prevRowExterior = new Dimensions(
                    node.State.SiblingsRowV.From,
                    node.State.SiblingsRowV.To);

                for (var row = 0; row < node.State.NumberOfSiblings; row++)
                {
                    // first, compute
                    var child = node.Children[row];
                    var rect  = child.State;

                    var top = prevRowExterior.To + (row == 0 ? ParentChildSpacing : SiblingSpacing);
                    child.State.MoveTo(rect.Left, top);
                    child.State.BranchExterior = new Rect(child.State.TopLeft, child.State.Size);

                    var rowExterior = new Dimensions(top, top + rect.Size.Height);

                    child = node.Children[row];
                    child.State.SiblingsRowV = rowExterior;

                    // re-enter layout algorithm for child branch
                    LayoutAlgorithm.VerticalLayout(state, child);

                    var childBranchBottom = child.State.BranchExterior.Bottom;

                    prevRowExterior = new Dimensions(rowExterior.From, Math.Max(childBranchBottom, rowExterior.To));
                }
            }
        }