Fixing #2 (tree)

Not yet finished. To be merged when the all the following items have been fixed:

- [ ] build a tree
- [ ] flatten it
- [ ] remove duplicates
- [ ] read in content and inline it