AddressBook using a binary search tree in java
<p>Hello I am writing an AddressBook application in java and I have written the whole program. The only thing is that its not working as expected and there are no errors in the code so i am unable to troubleshoot it. Any help would be much appriciated.</p>

<p>EDIT: This is not a duplicate question as this includes all the methods. The other one didn't have the main method and is incomplete and as it was closed i was forced to ask a new question. Makes sense?</p>

<pre><code>package com.addressbook;

public abstract class KeyedItem&lt;KT extends Comparable&lt;? super KT&gt;&gt; {
private KT searchKey;

public KeyedItem(KT key){
    searchKey = key;
}

public KT getKey(){
    return searchKey;
}
}




package com.addressbook;

public class People extends KeyedItem&lt;String&gt; {
private String address;
private String phone;


public People(String n, String a, String p){
    super(n);
    this.address = a;
    this.phone = p;
}

public void setAddress(String a){
    address = a;
}

public void setPhone(String p){
    phone = p;
}

public String toString(){
    return "Name:" + getKey() + "\nAddress:" + address + "\nPhone:" + phone;
}

public String getTheKey(){
    return getKey();
}
}



package com.addressbook;

public class BinaryNode{
// Friendly data; accessible by other package routines
private People people;      // The data in the node
private BinaryNode left;     // Left child
private BinaryNode right;    // Right child
// Constructors

public BinaryNode(People pe, BinaryNode l, BinaryNode r) {
    people = pe;
    left = l;
    right = r;
}

public BinaryNode(People pe) {
    people = pe;
    left = right = null;
}

public void setData(People p){
    people = p;
}

public String getSearch(){
    return people.getTheKey();
}

public People getData(){
    return people;
}

public BinaryNode getLeft(){
    return left;
}

public BinaryNode getRight(){
    return right;
}
}



package com.addressbook;

import com.addressbook.People;
import com.addressbook.BinaryNode;

public class AddressBook {
private BinaryNode root;

public AddressBook() {
    super();
}

public AddressBook(People p) {
    super();
    root = new BinaryNode(p);
}

public void insert(People p){
    insert(p, root);
}

public People get(String key) {
    BinaryNode node = root;
    while (node != null) {
        if (key.compareTo(node.getSearch()) == 0) {
            return node.getData();
        }
        if (key.compareTo(node.getSearch()) &lt; 0) {
            node = node.getLeft();
        } else {
            node = node.getRight();
        }
    }
    return null;
}

protected BinaryNode insert(People p, BinaryNode node) {
    if (node == null) {
        return new BinaryNode(p);
    }
    if (p.getTheKey().compareTo(node.getSearch()) == 0) {
        return new BinaryNode(p, node.getLeft(), node.getRight());
    } else {
        if (p.getTheKey().compareTo(node.getSearch()) &lt; 0) {    // add to left subtree
            insert(p, node.getLeft());
        } else {                                                // add to right subtree
            insert(p, node.getRight());
        }
    }
    return node;
}

public void remove(String key) {
    remove(key, root);
}

protected BinaryNode remove(String k, BinaryNode node) {
    if (node == null) { // key not in tree
        return null;
    }
    if (k.compareTo(node.getSearch()) == 0) { // remove this node
        if (node.getLeft() == null) { // replace this node with right child
            return node.getRight();
        } else if (node.getRight() == null) { // replace with left child
            return node.getLeft();
        } else {
            // replace the value in this node with the value in the
            // rightmost node of the left subtree
            node = getRightmost(node.getLeft());
            // now remove the rightmost node in the left subtree,
            // by calling "remove" recursively
            remove(node.getSearch(), node.getLeft());
            // return node;  -- done below
        }
    } else {        // remove from left or right subtree
        if (k.compareTo(node.getSearch()) &lt; 0) {
            // remove from left subtree
            remove(k, node.getLeft());
        } else {        // remove from right subtree
            remove(k, node.getRight());
        }
    }
    return node;
}

protected BinaryNode getRightmost(BinaryNode node) {
    assert(node != null);
    BinaryNode right = node.getRight();
    if (right == null) {
        return node;
    } else {
        return getRightmost(right);
    }
}

protected String toString(BinaryNode node) {
    if (node == null) {
        return "";
    }
    return node.getData().toString() + "(" + toString(node.getLeft()) + ", " +
        toString(node.getRight()) + ")";
}

public static void main(String[] arguments) {
    AddressBook tree = new AddressBook();

    People p1 = new People("person 1", "adresa 1", "404040404");
    People p2 = new People("person 2", "adresa 2", "4040434345");
    People p3 = new People("person 3", "adresa 3", "346363463");
    People p4 = new People("person 4", "adresa 4", "435346346");
    People p5 = new People("person 5", "adresa 5", "4363907402");

    tree.insert(p1);
    tree.insert(p2);
    tree.insert(p3);
    tree.insert(p4);
    tree.insert(p5);

    System.out.println(tree.get("person 1"));
    }
}
</code></pre>
