Fixed bug in IsRoot method