A way to select an element that can have a changing value

Right now I have 2 versions of an application I am testing with appium. Within the native inspector I found that on one application the accessibility ID for this element is lets just say “~apple” and on the other it is “~banana”. My question is, is there a way that I can within my scripts generalize this selection to be able to select both. I want to do this in a way that if one day there are multiple versions with different accessibility ID’s it shouldn’t have a problem selecting the element if it is in the same location on the page just named differently.

Note that I have considered the idea of using an xpath but the issue remains if there is multiple xpaths of the same type within a directory. For example, if there are 2 XCUIElementTypeStaticText elements within a window, I can’t generalize to just this because it may click the wrong one and I don’t know which name, apple or banana, to pass in as a name value to be more specific.