Whats the に doing in the next sentence?


> 心のスキマを埋める **には** ―恋がいちばん！

The context is the following: The girl is explaining to the guy that in order
to free the victim from a "ghost", he needs to fill their heart "void", so
shes saying that "The best way to do it is with love".

I've read "all" the uses of particle に and can't figure out what is it doing
there, "心のスキマを埋める" don't seems to me like the "location of existence" of
something, nor the "direction of the action" (there's not even an action in
that phrase right??, is not the "object of the verb" either, etc etc...

I know that the は particle here is doing like a "contrast" nuance, saying
something like "as compared to other methods", just not sure about the に
particle.

Thank you beforehand, and sorry if its a hard to explain question.




This usage is to indicate purpose, it is short for "~ためには". In context "In
order to fill the void of the victim's heart, love is the best!"  
「心のスキマを埋めるためには―恋がいちばん！」

[Read more here](https://www.imabi.net/inorderto.htm)

