I am trying to intersect two binary trees, and create a new binary tree with the nodes that are the same, but the following creates a stackOverflow error. Can anyone help me?

```
private OrderedSet<E> resultIntersect = new OrderedSet<E>();

public OrderedSet<E> intersection(OrderedSet<E> other) {
    OrderedSet<E> result = new OrderedSet<E>();
    if (other.root == null || root == null)
        return result;
    else if (height() == 0 && other.height() == 0
            && other.root.data.equals(root.data)) {
        result.insert(root.data);
        return result;
    } else {
        intersection(other, root, other.root);
        result = resultIntersect;
    }
    return result;
}

private void intersection(OrderedSet<E> other, TreeNode root1,
        TreeNode root2) {
    if (root1 == root2) {
        resultIntersect.insert(root1.data);
    }
    if (root1 == null || root2 == null) {
        return;
    }
    intersection(other, root1.left, root2.left);
    intersection(other, root1.right, root2.right);
}

```

*Edit*

I feel like this is closer to how I need to do it, but I still get the error.

```
private OrderedSet<E> resultIntersect = new OrderedSet<E>();

public OrderedSet<E> intersection(OrderedSet<E> other) {
    OrderedSet<E> result = new OrderedSet<E>();
    result = resultIntersect;
    return result;
}

private void intersection(OrderedSet<E> other, TreeNode t) {
    if (other.contains(t.data)) {
        resultIntersect.insert(t.data);
    }
    if(t.left != null)
        intersection(other, t.left);
    if(t.right != null)
        intersection(other, t.right);
}

```