private static int[] getMinPrefMaxSumSize(int[][] sizes) {
        int[] retSizes = new int[3];

        for (int i = 0; i < sizes.length;
                i++) {
            if (sizes[i] != null) {
                int[] size = sizes[i];
                for (int sType = LayoutUtil.MIN;
                        sType <= LayoutUtil.MAX;
                        sType++) {
                    int s = size[sType];

                    if (s != LayoutUtil.NOT_SET) {
                        if (sType == LayoutUtil.PREF) {
                            int bnd = size[LayoutUtil.MAX];
                            if (bnd != LayoutUtil.NOT_SET && bnd < s) {
                                s = bnd;
                            }
                            bnd = size[LayoutUtil.MIN];
                            if (bnd > s) {
                                // Includes s == LayoutUtil.NOT_SET since < 0.
                                s = bnd;
                            }
                        }

                        retSizes[sType] += s; // MAX compensated below.
                    }
                }

                // So that MAX is always correct.
                if (size[LayoutUtil.MAX] ==
                        LayoutUtil.NOT_SET) {
                    retSizes[LayoutUtil.MAX] =
                            LayoutUtil.INF;
                }
            }
        }

        return retSizes;
    }