static int getRightMostLeafUnderNode(int nodeOrder, int depth) {
        if (isLeaf(nodeOrder, depth)) {
            return nodeOrder;
        }

        int levelOfNode = getLevelOfNode(nodeOrder);
        int distanceFromLeafLevel = depth - levelOfNode - 1;
        int leftMostLeafUnderNode = getLeftMostLeafUnderNode(nodeOrder, depth);
        int leavesOfSubtreeUnderNode = getNodesOnLevel(distanceFromLeafLevel);

        return leftMostLeafUnderNode + leavesOfSubtreeUnderNode - 1;
    }
@Test
    public void testGetRightMostLeafUnderNode() {
        // depth 1
        assertEquals(0, MerkleTreeUtil.getRightMostLeafUnderNode(0, 1));

        // depth 2
        assertEquals(2, MerkleTreeUtil.getRightMostLeafUnderNode(0, 2));
        assertEquals(1, MerkleTreeUtil.getRightMostLeafUnderNode(1, 2));
        assertEquals(2, MerkleTreeUtil.getRightMostLeafUnderNode(2, 2));

        // depth 3
        assertEquals(6, MerkleTreeUtil.getRightMostLeafUnderNode(0, 3));
        assertEquals(4, MerkleTreeUtil.getRightMostLeafUnderNode(1, 3));
        assertEquals(6, MerkleTreeUtil.getRightMostLeafUnderNode(2, 3));

        // depth 4
        assertEquals(14, MerkleTreeUtil.getRightMostLeafUnderNode(0, 4));
        assertEquals(10, MerkleTreeUtil.getRightMostLeafUnderNode(1, 4));
        assertEquals(14, MerkleTreeUtil.getRightMostLeafUnderNode(2, 4));
        assertEquals(8, MerkleTreeUtil.getRightMostLeafUnderNode(3, 4));
        assertEquals(10, MerkleTreeUtil.getRightMostLeafUnderNode(4, 4));
        assertEquals(12, MerkleTreeUtil.getRightMostLeafUnderNode(5, 4));
        assertEquals(14, MerkleTreeUtil.getRightMostLeafUnderNode(6, 4));
    }