def startswith(x, lst):
    """ Select longest prefix that matches x from provided list(lst)

    :param x: input string
    :param lst: prefixes to compare with
    :return: longest prefix that matches input string if available otherwise None
    """
    longest_prefix = None
    for prefix in lst:
        if x.startswith(prefix):
            if longest_prefix is None or len(longest_prefix) < len(prefix):
                longest_prefix = prefix
    return longest_prefix