def generate_fw_query(project, seed, state, query=None):
    """Helper function to generate query dictionary for filtering Fireworks"""
    if not query:
        query = {}

    if project:
        query['spec.project_name'] = {'$regex': project}

    if seed:
        query['spec.seed_name'] = {'$regex': seed}

    if state:
        query['state'] = state.upper()

    return query