adds root(), up() and end() functions

root(), up() and end() functions are used for nesting tree traversal.
more info: http://goo.gl/Icvc7d