use tree_._TREE_LEAF instead of -2 for detecting leaves