public static <E extends Comparable<E>> BinaryTreeNode<E> deleteNodeRec(BinaryTreeNode<E> node, E value) {
		if(node == null) {
			return node;
		}
		
		if(value.compareTo(node.value)<=0) {
			node.left = deleteNodeRec(node.left, value);
		} else if(value.compareTo(node.value)>0) {
			node.right = deleteNodeRec(node.right, value);
		} else if(node.left!=null && node.right!=null) {
			BinaryTreeNode<E> minNode = node.right;
			BinaryTreeNode<E> parentNode = node;
			if(minNode.left == null) {
				parentNode.value = minNode.value;
				parentNode.right = minNode.right;
			} else {
				while(minNode.left!=null) {
					parentNode = minNode;
					minNode = minNode.left;
				}
				node.value = minNode.value;
				parentNode.left = deleteNodeRec(minNode, minNode.value);
			}
			
		} else {
			node=(node.left!=null)?node.left:node.right;
		}
		return node;
	}