You can get all elements by using findElements function.
Eg. You have 10 elments with similar ID "mySimilarId", you can first identify all 10 elements using findElements method. It will return List of WebElements.
java.util.List<WebElement> elements = driver.findElements(By.id("mySimilarId"));
From the variable elements you can access each element by using get() function.
elements.get(0) //will return you the first element.
elements.get(elements.size() - 1) //will return you the last element.
Hope that helps! Feel free to write back if you have any questions.