In reply to peter:
No, it will search up the hierarchy from where the call was made. The search ends when it gets to the $root of the hierarchy.
In my example above, test() was called from test1, and there was no test defined in test1. test1’s parent is top, so the search finds test there. This happens regardless of whether the definition of test1 is nested in the definition of top or not. What matters is the instance hierarchy. The only reason for nesting is hiding the definition of test1 from other modules so only top can instantiate test1.