public WinTreeItem GetCUITTreeItem(WinWindow w, string searchBy, string searchValue, int index)
        {
            Console.WriteLine("Inside function GetCUITMenuItem");
            WinTreeItem GetCUITTreeItem = new WinTreeItem(w);
            try
            {
                Playback.Initialize();
                switch (searchBy.Trim().ToLower())
                {
                    case "text":
                        {
                            if (index == -1)
                            {
                                GetCUITTreeItem.SearchProperties.Add(WinTreeItem.PropertyNames.Name, searchValue, PropertyExpressionOperator.Contains);
                                UITestControlCollection checkboxCollection = GetCUITTreeItem.FindMatchingControls();
                                GetCUITTreeItem = (WinTreeItem)checkboxCollection[0];
                            }
                            else
                            {
                                GetCUITTreeItem.SearchProperties.Add(WinTreeItem.PropertyNames.Name, searchValue);
                                UITestControlCollection checkboxCollection = GetCUITTreeItem.FindMatchingControls();
                                GetCUITTreeItem = (WinTreeItem)checkboxCollection[index];
                            }
                            break;
                        }

                    case "automationid":
                        {
                            if (index == -1)
                            {
                                GetCUITTreeItem.SearchProperties.Add(WinTreeItem.PropertyNames.ControlName, searchValue);
                                UITestControlCollection checkboxCollection = GetCUITTreeItem.FindMatchingControls();
                                GetCUITTreeItem = (WinTreeItem)checkboxCollection[0];
                            }
                            else
                            {
                                GetCUITTreeItem.SearchProperties.Add(WinTreeItem.PropertyNames.ControlName, searchValue);
                                UITestControlCollection checkboxCollection = GetCUITTreeItem.FindMatchingControls();
                                GetCUITTreeItem = (WinTreeItem)checkboxCollection[index];
                            }
                            break;
                        }
                    case "regulartext":
                        {
                            if (index == -1)
                            {

                                GetCUITTreeItem.SearchProperties.Add(WinTreeItem.PropertyNames.Name, searchValue, PropertyExpressionOperator.Contains);
                                UITestControlCollection checkboxCollection = GetCUITTreeItem.FindMatchingControls();
                                GetCUITTreeItem = (WinTreeItem)checkboxCollection[0];
                            }
                            else
                            {

                                GetCUITTreeItem.SearchProperties.Add(WinTreeItem.PropertyNames.Name, searchValue, PropertyExpressionOperator.Contains);
                                UITestControlCollection buttonCollection = GetCUITTreeItem.FindMatchingControls();
                                GetCUITTreeItem = (WinTreeItem)buttonCollection[index];

                            }
                            break;
                        }

                    default:
                        throw new Exception(_error);
                }

                Playback.Cleanup();
                Console.WriteLine("Found MenuItem and exiting function GetCUITMenuItem");
                return GetCUITTreeItem;

            }
            catch (Exception e)
            {
                var st = new StackTrace(e, true);
                var testFrame = st.GetFrame(0);
                for (int i = 0; i < st.FrameCount; i++)
                {
                    testFrame = st.GetFrame(i);
                    if (testFrame.GetFileName() != null)
                    {
                        if (testFrame.GetFileName().ToString().Contains("CUITFramework.cs") == true)
                        {
                            break;
                        }
                    }

                }
                // Get the top stack frame
                var frame = testFrame;
                // Get the line number from the stack frame
                var line = frame.GetFileLineNumber();
                logTofile(_eLogPtah, "Error in GetCUITCHeckbox and in line: " + line);
                throw new Exception(_error + "CUITRButton:" + System.Environment.NewLine + e.Message);
            }
        }