I'm trying to write a method, which returns the parent node of a given node.

```
public BinarySearchTreeNode<T> getParent(BinarySearchTreeNode<T> e) {
    if (e == null) {
        return null;
    }
    BinarySearchTreeNode<T> current = this.root;
    T eValue = e.getValue();
    while (current != null) {
        if (howManyChildren(current) == 0) {
            return null;
        } else if (eValue.equals(current.getLeft().getValue())
                || eValue.equals(current.getRight().getValue())) {
            return current;
        } else if (eValue.compareTo(current.getValue()) < 0) {
            current = current.getLeft();
        } else {
            current = current.getRight();
        }
    }
    return null;

}

```

However I receive NullPointerExceptions, when one or both of the children are null-nodes and equals tries to compare the value with null.
How do I go on to fix this? I'm still new to Java.