Modified how getTopParent() works