Change free_tree_elements to tree, not list
Remove unnecessary DOCUMENT key