added option to check self to getTopScopeParentWithClass