Recursive implementation of getChild()