Fixing starting times command by command and globally I have a lot of Command objects. Each command has lots of Task objects. Tasks and commands are related. Each command wants to know which task belongs to it. Where each task wants to know which command it belongs to.
class Command:

    def __init__(self, date):
        self.deadline = date
        self.tasks = []

    def add_task(self, task:Task):
        &quot;&quot;&quot;
        add a task to this command
        &quot;&quot;&quot;
        self.tasks.append(task)
        return task

    def has_task(self, task):
        return task in self.tasks

    def remove_task(self, task):
        &quot;&quot;&quot;
        Remove the task from this command.  After calling this, 
        the task is orphaned and the reference to the task should be discarded.
        &quot;&quot;&quot;
        self.tasks.remove(task)


class Task:
    def __init__(self, command:Command, duration:int):
        self.duration = duration
        self._command = command

    @property
    def command(self):
        &quot;&quot;&quot;
        Getter for self._command with sanity checking that 
        the task is not orphaned.
        &quot;&quot;&quot;
        if not self._command.has_task(self):
            raise ValueError(&quot;orphaned task&quot;)
        return self._command

class Problem:
    def __init__(self, commands:Dict[str,Command], tasks:Dict[str,Task]):
        self._commands = commands
        self._tasks = tasks


In the Problem object I feel there is some redundancy in the data between Commands and Tasks.
I fix starting times in two ways:

Fix the start time of tasks command by command.
This is why is a commands attribute in Problem.
Merge them and then fix the starting times.
This is why there is tasks attribute in Problem.

I need both ways to fix starting times. However, fixing the starting time of a task always depends on the deadline of the command to which it belongs.
I'm unsure if my design is good. Sometimes I need to go through the tasks command by command. Sometimes I need to consider all the tasks for the command they belong.
Is there a design pattern I can use?
Maintaining bidirectional relationships
Rather than this check:
    if not self._command.has_task(self):
        raise ValueError(&quot;orphaned task&quot;)

it would be better to mark the task as orphaned by nulling out its command. In other words,
def remove_task(self, task):
    &quot;&quot;&quot;
    Remove the task from this command.  After calling this, 
    the task is orphaned and the reference to the task should be discarded.
    &quot;&quot;&quot;
    task.command = None
    self.tasks.remove(task)

Having command as a simple, &quot;public&quot;, possibly-None member on Task is simpler. At most, I would give this a type hint of Optional[Command] in the constructor.
Types
Don't call date date; that's a commonly used class in a built-in library.
deadline should probably be of type datetime (not date), and duration should be of type timedelta, not int.