Implement mergelines support for sprofile_tree, and make it the default

This also:
- Parses the branches of the tree more efficiently
- Adds code comments to help other people understand what's being done