This sounds fairly straightforward. What have you tried?
The sub is given a hashref ($families) and the value of a key in the inner hash ('bart'). The key to look in is specified in the sub name ('kid'). In pseudocode, I would do something like this:
for each family surname in the hash (%$families)
get the value of the 'kid' key for the corresponding family hash
if the value is 'bart', return the surname
if the for loop completes the value wasn't found, so return or die
I hope that gets you started. Feel free to come back with more specific questions. Good luck!