Updated checkIfNode() and checkIfLeafNode() methods.