Formatting implementation using new tree

This PR adds implementation of code formatting that works atop of new tree. I would not suggest to review the code commit-by-commit as intermediate checkins here often contain non-relevant details that are ultimately removed in final implementation.
just to verify, you are intentionally leaving 'index' in the outer scope, and capturing in this lambda?  I feel like that's what the comment is trying to make explicit, but i just want to be sure.