public static Collection<Integer> compareTrees(MerkleTreeView local, MerkleTreeView remote) {
        Collection<Integer> deltaOrders = new LinkedList<>();
        MerkleTreeView baseTree = local.depth() <= remote.depth() ? local : remote;
        MerkleTreeView otherTree = local.depth() <= remote.depth() ? remote : local;
        int leafLevel = baseTree.depth() - 1;
        int numberOfLeaves = getNodesOnLevel(leafLevel);
        int leftMostLeaf = getLeftMostNodeOrderOnLevel(leafLevel);

        for (int leafOrder = leftMostLeaf; leafOrder < leftMostLeaf + numberOfLeaves; leafOrder++) {
            if (baseTree.getNodeHash(leafOrder) != otherTree.getNodeHash(leafOrder)) {
                deltaOrders.add(leafOrder);
            }
        }

        return deltaOrders;
    }
@Test
    public void testCompareTreesCatchesCollision() {
        int numberOfLocalTreeLeaves = 4;
        int[] localTreeLeaves = new int[numberOfLocalTreeLeaves];
        for (int i = 0; i < numberOfLocalTreeLeaves; i++) {
            localTreeLeaves[i] = i;
        }

        int numberOfRemoteTreeNodes = 4;
        int[] remoteTreeLeaves = new int[numberOfRemoteTreeNodes];
        for (int i = 0; i < numberOfRemoteTreeNodes; i++) {
            remoteTreeLeaves[i] = i;
        }

        // we cause a collision here that compareTrees() will notice
        // hash(node5,node6) will produce the same hash for node2 in both trees
        // localTreeLeaves: hash(2,3)=5
        // remoteTreeLeaves: hash(1,4)=5
        localTreeLeaves[2] = 1;
        localTreeLeaves[3] = 4;

        MerkleTreeView localTreeView = new RemoteMerkleTreeView(localTreeLeaves, 3);
        MerkleTreeView remoteTreeView = new RemoteMerkleTreeView(remoteTreeLeaves, 3);

        Collection<Integer> deltaOrders = MerkleTreeUtil.compareTrees(localTreeView, remoteTreeView);
        assertEquals(localTreeView.getNodeHash(0), remoteTreeView.getNodeHash(0));
        assertEquals(localTreeView.getNodeHash(2), remoteTreeView.getNodeHash(2));
        assertEquals(2, deltaOrders.size());
        assertTrue(deltaOrders.containsAll(asList(5, 6)));
    }