private StateSave GetStateInIElement(string stateName, IElement element, string category = null) { if (element != null) { if (category == "VariableState") { category = null; } return element.GetStateRecursively(stateName, category); } else { return null; } }