In Landau--de Gennes theory, the free energy f of liquid crystals is expanded into powers of a symmetric, traceless tensor order parameter ${Q}_{\ensuremath{\alpha}\ensuremath{\beta}}$ and its derivatives ${Q}_{\ensuremath{\alpha}\ensuremath{\beta}}$,\ensuremath{\gamma}. The expansion is subject to the condition that f is a scalar, i.e., invariant under all rotations of the group SO(3). Using the method of integrity basis, we have established the most general SO(3)-invariant free-energy density up to all powers in ${Q}_{\ensuremath{\alpha}\ensuremath{\beta}}$ and up to second order in ${Q}_{\ensuremath{\alpha}\ensuremath{\beta}}$,\ensuremath{\gamma}. It turns out that this free-energy density is composed of 39 invariants, which are multiplied by arbitrary polynomials in Tr${Q}^{2}$ and Tr${Q}^{3}$. On the other hand, these 39 invariants can be expressed as polynomials of 33 so-called irreducible invariants. Interestingly, among the irreducible invariants there are only three chiral terms (i.e., linear in ${Q}_{\ensuremath{\alpha}\ensuremath{\beta}}$,\ensuremath{\gamma}). They locally give rise to three independent helix modes in chiral, biaxial liquid crystals. This conclusion generalizes results of Trebin [J. Phys. (Paris) 42, 1573 (1981)] and Govers and Vertogen [Phys. Rev. A 31, 1957 (1985); 34, 2520 (1986)] and contradicts a statement of Pleiner and Brand [Phys. Rev. A 24, 2777 (1981); 34, 2528 (1986)], according to which only one twist term is supposed to exist.Some possibilities, leading to a smaller number of the irreducible invariants, are also discussed in detail. These special forms of the elastic free-energy expansion are obtained by imposing additional symmetry restrictions on the field Q. One arrives, for example, at a system of ``soft biaxial nematic'' phases by requiring Tr${Q}^{2}$=const, at a system of biaxial phases with Tr${Q}^{3}$=const, or at a system with fixed moduli of the order parameter (``hard biaxial'' phases) by requiring both. In all cases the number of irreducible invariants is reduced significantly. For example, hard biaxial phases can be described using only 12 irreducible invariants among which three are chiral. Furthermore, three irreducible invariants can be eliminated if surface terms vanish. In all limiting cases relations between irreducible invariants are given explicitly.