Orthogonal and unitary tensor decomposition from an algebraic perspective