I will use braket-notation, but my question is not specific to quantum mechanics. Instead, I would be interested in a general answer for operators in some Hilbert space. Let $H$ be a Hermitian operator with eigenstates $|i\rangle$, so that $H |i\rangle = E_i |i\rangle$, where some eigenvalues may possibly be degenerate. Now consider another Hermitian operator $A$. This operator can be represented as a matrix in the basis $\{|i\rangle\}$ of the eigenvectors of $H$, with elements $$ A_{ij} = \langle i|A|j \rangle $$ Hermiticity of $A$ then requires $A_{ji} = A_{ij}^*$. In general, however, these matrix elements may be complex. My question is the following: Is it possible to formulate a condition on $A$, probably in relation to $H$, such that the matrix elements of $A$ in the basis formed by the eigenvectors of $H$ are real, $A_{ji} = A_{ij}$, if this condition is satisfied?
I think in some situations a simple multiplication by a phase factor may be sufficient. Assuming the $A_{ij}$ are complex, one may write $$ A_{ij} = |A_{ij}| \, e^{i \phi_{ij}} $$ Now consider transforming to new basis vectors given by $|i'\rangle = e^{i \nu_i} |i\rangle$. These are still eigenstates of $H$ and the matrix elements of $A$ in this new basis are given by $$ A_{ij}' = |A_{ij}| \, e^{i (\phi_{ij} + \nu_j - \nu_i)} $$ So if there is a solution for the $\nu_i$ to the set of $n^2$ equations (where $n$ is number of eigenstates of $H$, so dimension of Hilbert space) given by $$ \phi_{ij} + \nu_j - \nu_i = 0, $$ then the operator $A$ can be represented by a real matrix in that basis. I believe that such a solution exists in the case when the phases satisfy the relation $\phi_{ij} + \phi_{jk} = \phi_{ik}$. However, I don't think the phases of a general operator $A$ necessarily satisfy this condition. If they do not, there may not be a solution to the system of equations since there are $n^2$ constraints, but only $n$ variables $\nu_i$ to solve for.
Is there a general relation between $A$ and $H$ that leads to a representation of $A$ in terms of a matrix with real elements?