avoid calculate rwr for subtree rooted by sample, move global variables
to the top, add docs.
Add validation for input root_node, avoid stupid problems.