new parameters 'root' and 'start level'; bugfix; some clean-up

This patch introduces two new format parameters:
* root - the root page of the tree, everything not under this root will be dropped
* start level - the start level of the tree, e.g. for integrating it into another tree

Bugfix: root elements were not included

Additionally the patch contains optimization and cleaning up of the code.

Change-Id: I65cc4854b1292088848f31c8a75d2931029bc4e4