Acylindrical hyperbolicity of groups acting on trees