Computing Cartan subalgebras of Lie algebras