Bug fix in isLeaf