Hello.
As you said there was a factor that impacted you and affected your state of mind due to which you are unable to sleep well. If the cause factor is not dealt with appropriately it will continue to hinder you. Through counseling you can talk about what had happened and can even find closure for the same. Once you talk about it and bring out the feelings, you will feel relieved and be able to sleep better.
All the very best.
Next Steps
Try to speak to a counselor to help deal with the issue.
Health Tips
If you have certain someone whom you trust and love, talk to them about the same. Sharing your feelings will help you to deal with it better.