<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def ensure_header(self, header: BlockHeader=None) -> BlockHeader: """ Return ``header`` if it is not ``None``, otherwise return the header of the canonical head. """

        if header is None:
            head = self.get_canonical_head()
            return self.create_header_from_parent(head)
        else:
            return header