def coerceBigInt(x):
    """
    Retrieves a BigInt from @x or returns None if @x is not a type that can be
    converted.
    """
    # BigInt's are easy.
    if isinstance(x, BigInt):
        return x

    # Convert ints and longs using the constructor
    elif isinstance(x, (long, int)):
        return BigInt(x)

    else:
        return None
Retrieves a BigInt from @x or returns None if @x is not a type that can be
    converted.