def following_key(key):
    """
    Returns the key immediately following the input key - based on the Java implementation found in
    org.apache.accumulo.core.data.Key, function followingKey(PartialKey part)
    :param key: the key to be followed
    :return: a key that immediately follows the input key
    """
    if key.timestamp is not None:
        key.timestamp -= 1
    elif key.colVisibility is not None:
        key.colVisibility = following_array(key.colVisibility)
    elif key.colQualifier is not None:
        key.colQualifier = following_array(key.colQualifier)
    elif key.colFamily is not None:
        key.colFamily = following_array(key.colFamily)
    elif key.row is not None:
        key.row = following_array(key.row)
    return key