Only use outermost nodes to find common ancestors

Can greatly reduce the number of function calls made
allow for executing sections, give various operations different weights
Rev to 1.0 and re-release under Apache 2.0 License
Fix license info in second XQuery file
Change the tree placement to be tail recursive