def METHOD_NAME(state, days, signal_id=None):
    """
    Select signals for deletion.
    Selected signals are in given state and older than some number of days.
    """
    # Select Signals that are in the given states and the state has been set more than X days ago
    # Only select normal signals or parent signals
    queryset = Signal.objects.filter(parent_id__isnull=True, status__state=state,
                                     status__created_at__lt=timezone.now() - timezone.timedelta(days=days))
    if signal_id:
        # A specific Signal ID was given, only select that Signal
        queryset = queryset.filter(id=signal_id)
    return queryset