If you are trying to program a tree, here I have a suggestion...

Binary Tree Thread