Fix bug in balanced path

Fixed a bug with precedence when the comparison function is not
enclosed in parentheses
Add support for comparator in merge
Merge pull request #322 from roshanr95/merge

Merge