Returns a Node pointing to obj.
    
    If obj is a ctypes-derived class, an UnboundNode is returned.  If obj is
    an instance of such a class, then a BoundNode will be returned.
    
    If the optional path is provided, it is a string to look up searching
    down the original source node, such as '.overhead.window[2].page'

def findnode(obj, path=''):
    """Returns a Node pointing to obj.
    
    If obj is a ctypes-derived class, an UnboundNode is returned.  If obj is
    an instance of such a class, then a BoundNode will be returned.
    
    If the optional path is provided, it is a string to look up searching
    down the original source node, such as '.overhead.window[2].page'
    """
    if isclass(obj):
        node = _createunbound(obj)
    else:
        node = _createbound(obj)
    
    # And walk it down.
    pathparts = re.split(r'\]?(?:[[.]|$)', path)
    for part in pathparts:
        if not part:    continue
        try:
            idx = int(part)
            node = node[idx]
        except ValueError:
            node = node[part]
    return node