public void add(T element) {
		// create a node for that element
		Node z = new Node();
		z.key = element;

		Node y = null;
		Node x = root; // the root

		// loop while x is not null
		while (x != null) {
			// set y to x
			y = x;
			// compare the key of the element to be inserted with x
			int compare = z.key.compareTo(x.key);
			// if smaller we go in the left subtree
			if (compare < 0) {
				x = x.left;
			} else {
				// otherwise, it it is the same and we don,t allow
				// multiple instances of the same item
				if (compare == 0 && !allowSameElementMultipleTimes) {
					return; // we don't add it
				}
				// otherwise go the right subtree
				x = x.right;
			}
		}
		// after the previous loop has terminated, we have found
		// the place where the new node z should be inserted (as a child of y) so
		// we will insert it there.
		
		// we set the parent of z as y
		z.parent = y;
		if (y == null) { // case of an empty tree
			root = z;  // set z as the root
		}// if z is small than y 
		else if (z.key.compareTo(y.key) < 0) {
			// append as left child
			y.left = z;
		} else {
			// otherwise append as right child
			y.right = z;
		}
		// increase the number of elements in the tree
		size++;
	}