def normalize_links
      stack = @links.dup

      @links.clear

      while link = stack.pop
        relationship = case link
          when Symbol, String
            @relationships[link]
          else
            link
        end

        if relationship.respond_to?(:links)
          stack.concat(relationship.links)
        elsif !@links.include?(relationship)
          @links << relationship
        end
      end

      @links.reverse!
    end
def normalize_links
      stack = @links.dup

      @links.clear

      while link = stack.pop
        relationship = case link
          when Symbol, String
            @relationships[link]
          else
            link
        end

        if relationship.respond_to?(:links)
          stack.concat(relationship.links)
        elsif !@links.include?(relationship)
          @links << relationship
        end
      end

      @links.reverse!
    end
Normalize links to Query::Path

 Normalization means links given as symbols are replaced with
 relationships they refer to, intermediate links are "followed"
 and duplicates are removed

 @api private