Add support for cursor closing
Implement tree building from traversal list