Fix bugs in get tree support.

Previous version will count parent node as leaf node, making
support a bit larger.