public TreeMap<Integer, Integer> getPowersOfTwoDecomposition(BigInteger x) {
        // Special Cases
        if (x.compareTo(BigInteger.ZERO) == 0) {
            return null;
        }
        TreeMap<Integer, Integer> result = new TreeMap<Integer, Integer>();
        if (x.compareTo(BigInteger.ONE) == 0) {
            result.put(0, 1);
            return result;
        }
        TreeMap<Integer, BigInteger> powersOfTwo = getPowersOfTwo(x);
        Integer n;
        BigInteger powerofTwo;
        BigInteger remainder = new BigInteger(x.toString());
        Iterator<Integer> powersOfTwoDescendingKeySet_Iterator = powersOfTwo.descendingKeySet().iterator();
        while (powersOfTwoDescendingKeySet_Iterator.hasNext()) {
            if (remainder.compareTo(BigInteger.ZERO) == 1) {
                n = powersOfTwoDescendingKeySet_Iterator.next();
                powerofTwo = powersOfTwo.get(n);
                if (powerofTwo.compareTo(remainder) != 1) {
                    remainder = remainder.subtract(powerofTwo);
                    Generic_Collections.addToTreeMapIntegerInteger(result, n, 1);
                }
            } else {
                break;
            }
        }
        //System.out.println("remainder " + remainder);
        if (remainder.compareTo(BigInteger.ZERO) == 1) {
            Generic_Collections.addToTreeMapIntegerInteger(
                    result,
                    getPowersOfTwoDecomposition(remainder));
        }
        return result;
    }