Elimination in free Lie algebras and free restricted Lie algebras