Changed parent from being a reference to a function.
Fixed incorrect parent being returned.