def find_longest_matches(nodeid, conditions):
    """Find the longest matches of the given test case name in the conditions list.

    This is similar to longest prefix match in routing table. The longest match takes precedence.

    Args:
        nodeid (str): Full test case name
        conditions (list): List of conditions

    Returns:
        str: Longest match test case name or None if not found
    """
    longest_matches = []
    max_length = -1
    for condition in conditions:
        # condition is a dict which has only one item, so we use condition.keys()[0] to get its key.
        if nodeid.startswith(condition.keys()[0]):
            length = len(condition)
            if length > max_length:
                max_length = length
                longest_matches = []
                longest_matches.append(condition)
            elif length == max_length:
                longest_matches.append(condition)
    return longest_matches