/// <summary>
        /// Adds tree view items for each check. Optional filter is applied. If <paramref name="filterText"/> parameter is null or empty, no filtering is applied.
        /// If <paramref name="filterText"/> is not empty, then it is broken into chunks (each separated by space) and each chunk is used
        /// to see whether any check property {name, tags}, case-insensitively, matches the filter. If all filter items match any of the check properties, then a check is shown.
        /// Otherwise the check is hidden from the list.
        /// </summary>
        /// <param name="parentNode">Node under which checks are to be added.</param>
        /// <param name="filterText">Filter string, entered in a text box. When empty (or only whitespaces), no filtering is applied, otherwise, each keyword (separated by whitespaces) is used to filter on anything about a check.</param>
        private void AddOrUpdateChecks(ItemsControl parentNode, string filterText)
        {
            try
            {
                parentNode.BeginInit();

                foreach (var check in Configuration.GetAllChecks())
                {
                    #region Enable filter

                    if (!CheckMatchesFilter(check, filterText))
                    {
                        //If the check doesn't match the filter, remove if from the list if it was added.
                        var existingUI = parentNode.Items.ToList <TreeViewItem>()
                                         .Where(child => (child.Header as StackPanel).Children.ToList <Label>().First().Content.ToString().Equals(check));
                        if (existingUI.Count() == 0)
                        {
                            continue;
                        }
                        parentNode.Items.Remove(existingUI.First());
                        continue;
                    }

                    #endregion

                    var checkPanel = new StackPanel {
                        Orientation = Orientation.Horizontal
                    };
                    checkPanel.Children.Add(ResourceHelper.GetImage(IconType.Check, 16, 16));
                    checkPanel.Children.Add(new CheckBox {
                        Name = "CheckCheckBox"
                    });
                    checkPanel.Children.Add(new Label {
                        Content = check, Name = "CheckName"
                    });

                    AddOptionalTagIconWithTooltip(checkPanel, Configuration.GetCheckTags(check));

                    #region Enable removal of tags when the user selects context menu

                    var checkTagRemoval = checkPanel.Children.ToList <Image>()
                                          .Where(i => !ReferenceEquals(null, i.Tag))
                                          .Where(i => i.Tag.ToString() == "RemoveTag");
                    if (checkTagRemoval.Count() == 1)
                    {
                        var removalIcon = checkTagRemoval.First();
                        var menuItems   = removalIcon.ContextMenu;

                        foreach (var item in menuItems.Items.ToList <MenuItem>())
                        {
                            var currentItem         = item;
                            var currentCheck        = check;
                            RoutedEventHandler mbeh = delegate { Configuration.RemoveTagFomChecks(currentItem.Tag.ToString(), new[] { currentCheck }); UpdateViewToMatchData(); };
                            item.Click += mbeh;
                        }
                    }

                    #endregion

                    //See if there already is a UI item for this check
                    var existingPanels = parentNode.Items.ToList <TreeViewItem>()
                                         .Where(child => (child.Header as StackPanel).Children.ToList <Label>().First().Content.ToString().Equals(check));

                    TreeViewItem checkNode = null;
                    if (existingPanels.Count() == 0)
                    {
                        checkNode = new TreeViewItem {
                            Header = checkPanel
                        };
                        parentNode.Items.Add(checkNode);
                    }
                    else
                    {
                        //Replace existing panel with the new panel.
                        checkNode = existingPanels.First();
                        var oldPanel = checkNode.Header as StackPanel;
                        checkNode.Header = checkPanel;
                        //Update check check box status
                        checkPanel.Children.ToList <CheckBox>().First().IsChecked = oldPanel.Children.ToList <CheckBox>().First().IsChecked;
                    }
                }
            }
            finally
            {
                parentNode.EndInit();
            }
        }