private AT GetTargetItem(string deviceNameVm, int targetIndex) { AT itemTarget; if (targetIndex > 0) // Show 2 identical devices in VM. { var itemTargets = new AT().GetElements(name: deviceNameVm, treeScope: ATElement.TreeScope.Descendants, controlType: ATElement.ControlType.MenuItem); itemTarget = itemTargets.GetATCollection()[targetIndex]; } else { itemTarget = new AT().GetElement(name: deviceNameVm, treeScope: ATElement.TreeScope.Descendants, controlType: ATElement.ControlType.MenuItem); } return(itemTarget); }