James 1:27 ... Pure religion and undefiled before God and the Father is
this, To visit the fatherless and widows in their affliction, and to
keep himself unspotted from the world.
Exhortation: Joan Boney ... apostle/prophet
In the above scripture, "to visit" means "to judge" ... in the case of the fatherless and widows we go check on them to see if they have any need that we are able to provide.
Keeping ourselves unspotted from the world is usually a matter of committing the troubling thought to God in prayer. If we are reminded of a scripture or dream, we focus on that knowing it is given by Holy Spirit to help and comfort and instruct us in the troubling matter.
Please read: Dealing with destructive thoughts