private void checkDepth(TreeNode node, int depth) {
        if (node == null) {
            return;
        }

        depth ++;

        TreeNode left = node.left;
        TreeNode right = node.right;

        if (left == null && right == null) {
            if (depth < minDepth || minDepth == 0) {
                minDepth = depth;
            }
        } else if (depth < minDepth || minDepth == 0) {
            checkDepth(left, depth);
            checkDepth(right, depth);
        }
    }