The ‘preceding-sibling’ xpath axes finds elements in the oposite direction.
In the example below the appium evaluates this xpath “//a[text() = ‘Videos’]//preceding-sibling::a[1]” as node at last index, finds Photos instead.