Recurive function propegates through actors

Hello i have this system setup so that a platform actor has 4 macro variables in it
which contain a pointer to an adgesent actor (if some side doesnt have an actor connected defult value is nullptr)
it also has an Index value(if i player standing on it the index is 0 )

in each one of the actors seen above i want to have a value for How far is the actor with the Index 0
by saying how far i mean how many steps to adgesent platforms i havve to make in order to reach Index 0

To My Question :
i had an idea to make a recursive function
if one of the actors concted has the Index 1 the function will return 1
if the index is not 0 but actor is found(lets call him actor* a)
i want for the function to call it self to run on the adgesent actor and then add 1 to the result

is it even possible ??