Bug in tree height

There is a bug in finding the tree height.
If we create a tree with these items:


      var tree = new Tree();
        tree.insert(7);
        tree.insert(4);
        tree.insert(9);
        tree.insert(1);
        tree.insert(6);
        tree.insert(8);
        tree.insert(10);
        tree.insert(11);
        tree.insert(12);
        System.out.println(tree.height());

we get a NullPointerException in isLeaf method.

To solve this we need to add root == null || check in the if statement

    private int height(Node root) {
        if (root == null || isLeaf(root)) return 0;
        return 1 + Math.max(height(root.leftChild), height(root.rightChild));
    }