fix traversing scope ancestors