traceback function finds path to root element of hierarchy