GetMesh() is undefined?

Wow this is driving me crazy. Here is how it works…

UAnimInstance* AnimInstance = OwnerComp.GetAIOwner()->GetCharacter()->GetMesh()->GetAnimInstance();

Does anybody have tutorial or can explain a way to play an animation from a behavior tree task node in C++?