def METHOD_NAME(cls, lookup_query: VariableValue) -> Set[str]:
    """Calculate any dependencies required to perform this lookup.
    Note that lookup_query may not be (completely) resolved at this time.
    Args:
        lookup_query: Parameter(s) given to this lookup.
    Returns:
        Stack names this lookup depends on.
    """
    # try to get the stack name
    stack_name = ""
    for data_item in lookup_query:
        if not data_item.resolved:
            # We encountered an unresolved substitution.
            # StackName is calculated dynamically based on context:
            #  e.g. ${output ${default var::source}.name}
            # Stop here
            return set()
        stack_name += data_item.value
        match = re.search(r"(::|\.)", stack_name)
        if match:
            stack_name = stack_name[0 : match.start()]
            return {stack_name}
            # else: try to append the next item
    # We added all lookup_query, and still couldn't find a `::`...
    # Probably an error...
    return set()