I am using the JQuery plugin jsTree, http://www.jstree.com/ I am able to expand the whole tree with the following method:
$(\"#tree\").jstree(\"open_all\");
Your code for open branch is correct.
For example. Source of tree:
TEST1 TEST2 TEST3
Open node:
$("#treeTask").jstree("open_node", $("#node_38"));