Is there a function out there that is able to get the second to last child? or is there a clever way to achieve this?

essentially say the tree was

a
b
c
d
e

I want to be able to get at 'd' without having to explicitly state d. Plus there will be new data added all the time, so I need to plot the change from point d to point e and once point f is added the difference between point e and point f. So always the child right before the lastChild.

Thanks.