Fix AttributeError when there’s no head