Fixed error in getTopLevelParent()