public void ParseCommand(string command)
 {
     commandElements = command.Split(':').ToList();
     if (commandElements[0].ToLower() == "mode")
     {
         SetMode(commandElements[1]);
         commandElements.Clear();
     }
     else if (commandElements[0].ToLower() == "branch")
     {
         if (mode == Mode.NULL)
         {
             Console.WriteLine("Mode not set.");
         }
         else if (commandElements.Count != 2)
         {
             Console.WriteLine("Wrong branch format.");
         }
         else
         {
             BuildBranch();
             commandElements.Clear();
         }
     }
     else if (commandElements[0].ToLower() == "leaf")
     {
         if (mode == Mode.NULL)
         {
             Console.WriteLine("Mode not set.");
         }
         else if (commandElements.Count != 3)
         {
             Console.WriteLine("Wrong leaf format.");
         }
         else
         {
             BuildLeaf();
             commandElements.Clear();
         }
     }
     else if (commandElements[0].ToLower() == "close")
     {
         if (mode == Mode.NULL)
         {
             Console.WriteLine("Mode not set.");
         }
         else
         {
             CloseBranch();
             commandElements.Clear();
         }
     }
     else if (commandElements[0].ToLower() == "print")
     {
         if (mode == Mode.NULL)
         {
             Console.WriteLine("Mode not set.");
         }
         else
         {
             root = builder.GetDocument();
             Console.WriteLine(root.Print(0));
             commandElements.Clear();
         }
     }
     else if (commandElements[0].ToLower() == "help")
     {
         Help();
         commandElements.Clear();
     }
     else
     {
         Console.WriteLine("Bad input!");
         commandElements.Clear();
     }
 }