The documentation for the command rank() says the following:
Deprecated. Reference a child node by rank
Parameters
(obj parent, num index)
Description
This command is deprecated. Use treenode.rank.
However, treenode.rank doesn't give you a reference to the child node. it gets/sets the rank of a node. It should say to use treenode.subnodes