private void delete_helper(Node node, Node prev, int direction, int target) {
        if (node == null)
            return;
        int val = node.val;
        if (val == target) {
            if (node.mid == null) {
                // delete it
                if (prev != null) {
                    switch (direction) {
                        case 0:
                            prev.left = null;
                            break;
                        case 1:
                            prev.mid = null;
                            break;
                        case 2:
                            prev.right = null;
                            break;
                        default:
                            break;
                    }
                } else {
                    node = null;
                }
                return;
            } else {
                delete_helper(node.mid, node, 1, target);
            }
        } else if (val < target) {
            delete_helper(node.right, node, 2, target);
        } else {
            delete_helper(node.left, node, 0, target);
        }
    }