Please don't post the same question in multiple forums.
You can use simple XPath selection to get the last node of any repeating section, so for example if I wanted to access field1 in the last group2 group (and group2 is repeating) I would use in C#:
XPathNavigator lastField1 = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:group1/my:group2[last()]/my:field1", NamespaceManager);