How can I create a long name chain?

Is there a way in Rstudio to create the longest "name chain" within data. For example, if there are two columns in data a First Name column and Last Name Column. If both columns are filled with John, in the first name column then Chandler in the Last Name column, there a way to find another piece of data where Chandler is in the First Name column then another last name and then continuing on to make a long name chain.

Example:
John Chandler
Chandler Brian
Brian Michael
Michael Parker
Parker Tyler
Tyler Jones
STOP (Because the data does not have someone with a first name as Jones)

Here is a test data set to try and find the longest name chain given a column of first names and a column of last names

First.Name<-c("John", "James", "Jack", "Jill", "Corey", "Callie", "Sofie", "Josie", "Lilly", "Luke", "Jane", "Sara", "Chandler","Flora","Parker","Preston")
Last.Name<-c("Smith","Flora","Chandler","Jack","John","Reeves","Preston","Parker","James","Brooks","Johnson","Smith","Krause","Casey","Corey","Lilly")

I tried to run >intersect(First.Name,Last.Name), which gave me the names that are in both columns but do not know where to go from there

A post was merged into an existing topic: Create a long name chain using R

Please do not duplicate open topics