private Variable BuildPathToParent(AutomationElement element) { var parent = GetParentOrMainWindow(element); var parentVariable = _existingVariables.Find(parent) ?? BuildPathToParent(parent); var variableName = CreateVariableName(element); if (element.Properties.AutomationId.TryGetValue(out var automationId) && !string.IsNullOrEmpty(automationId)) { _builder.Append($"${variableName} = ${parentVariable.Name}.FindFirstDescendant($uia.ConditionFactory.ByAutomationId(\"{automationId}\"))"); }