private Link maybeSwitch(Link link){
        Link secondLink = linkQueue.peek();
        if(link != null && secondLink != null){
            if(
                    link instanceof BackLink &&
                    link.getRank() == secondLink.getRank()&&
                    !(secondLink instanceof ShortcutLink)){
                linkQueue.poll();
                linkQueue.add(link);
                link = secondLink;
            }
            else if( link.getRank() == secondLink.getRank() && secondLink instanceof MatchLink){
                linkQueue.poll();
                linkQueue.add(link);
                link = secondLink;
            }
        }

        return link;
    }