Avoid traversing unnecessary paths while expanding generics