better checking when isLeaf is False