for elt in itertools.chain.from_iterable(node):
    do_stuff_to_each(elt)
try:
    do_stuff_to_last(elt)
except NameError:
    pass
Python How to I check if last element has been reached in iterator tool chain?