private void inputTextbox_TextChanged(object sender, TextChangedEventArgs e)
        {
            try
            {
                warningText.Visibility = Visibility.Collapsed;
                baseTree.Visibility    = Visibility.Visible;
                baseTree.Clear();

                string[] token = inputTextbox.Text.Split(' ');

                Treap <char> treap = null;

                for (int i = 0; i < token.Length; i++)
                {
                    var  splitToken = token[i].Split('/');
                    char c          = splitToken[0][0];
                    int  priority   = int.Parse(splitToken[1]);

                    if (treap == null)
                    {
                        treap = new Treap <char>(c, priority);
                    }
                    else
                    {
                        treap = treap.Insert(c, priority);
                    }
                }

                outputText.Text = treap.ConvertTreeToString();

                var root = baseTree.AddRoot(treap.Data + "/" + treap.Priority);

                bool hasLeft  = treap.Left != null;
                bool hasRight = treap.Right != null;

                if (hasRight && !hasLeft)
                {
                    var noElementTree = baseTree.AddNode(treap, root);
                    noElementTree.Content = new NullChild(true);
                }

                AddTree(treap.Left, root);
                AddTree(treap.Right, root);

                if (hasLeft && !hasRight)
                {
                    var noElementTree = baseTree.AddNode(treap, root);
                    noElementTree.Content = new NullChild(false);
                }
            }
            catch {
                warningText.Visibility = Visibility.Visible;
                baseTree.Visibility    = Visibility.Collapsed;
                outputText.Text        = "Input format is not valid.";
            }
        }
        private void AddTree(Treap <char> tree, TreeNode parent)
        {
            if (tree == null)
            {
                return;
            }

            TreeNode node;

            node = baseTree.AddNode(tree, parent);
            var tBlock = new TextBlock();

            tBlock.Text       = tree.Data.ToString() + " / " + tree.Priority;
            tBlock.Foreground = Brushes.Black;
            node.Content      = tBlock;

            bool hasLeft  = tree.Left != null;
            bool hasRight = tree.Right != null;

            if (hasRight && !hasLeft)
            {
                var noElementTree = baseTree.AddNode(tree, node);
                noElementTree.Content = new NullChild(true);
            }

            if (tree.Left != null)
            {
                AddTree(tree.Left, node);
            }

            if (tree.Right != null)
            {
                AddTree(tree.Right, node);
            }

            if (hasLeft && !hasRight)
            {
                var noElementTree = baseTree.AddNode(tree, node);
                noElementTree.Content = new NullChild(false);
            }
        }