Adding an extra class to the last element of the navigation/tree menu
You should be able to apply an additional loop to iterate by specific menu_level. Here is an example of a twig template that iterates over menu level variable:
How to add classes to menu items in navigation twig template

Then use a condition to set the class within the for loop such as:

loop.last ? 'last'

See all the variables associated with for loops in twig here: 
https://twig.symfony.com/doc/2.x/tags/for.html