Fixed internal error when editing certain themes and epics

This fixes that themes and epics with children could not be edited without getting Internal Server error during the update after saving (the edit was saved anyway though).