Get last xpath of specific id

For a specific object whose xpath is defined as below

This div keeps on repeating like shown below

My requirment is how to find the last xpath of the @id=“start” so that we can get the text associated with it.
The xpath is dynamic and from what I have seen the incremental portion can be modified with a variable. My problem is I do not know the dynamic value to set for that variable and so am trying to find the last or max value.
Any suggestions appreciated


this would work.

def String findLastElement() {
	String pathTemplate = "//[@id='start']/div[2]/div[2]/div[5]/div[%d]/div"
	int i = 1
	TestObject to = new TestObject()
	to.addProperty('xpath', ConditionType.EQUALS, String.format(pathTemplate, i))
    while(WebUI.waitForElementPresent(to, 1)) {
		to.findProperty("xpath").setValue(String.format(pathTemplate, i))
	// last existing index is i-1
	return String.format(pathTemplate, i-1)

println findLastElement()