Impl of treenode test in java