public boolean duplicatesInStack(LinkedList<SchemaTableTree> distinctQueryStack) {
        Set<SchemaTable> alreadyVisited = new HashSet<>();
        for (SchemaTableTree schemaTableTree : distinctQueryStack) {
            if (!alreadyVisited.contains(schemaTableTree.getSchemaTable())) {
                alreadyVisited.add(schemaTableTree.getSchemaTable());
            } else {
                return true;
            }
        }
        return false;
    }
public boolean duplicatesInStack ( LinkedList < SchemaTableTree > distinctQueryStack ) { Set < SchemaTable > alreadyVisited = new HashSet < > ( ) ; for ( SchemaTableTree schemaTableTree : distinctQueryStack ) { if ( ! alreadyVisited . contains ( schemaTableTree . getSchemaTable ( ) ) ) { alreadyVisited . add ( schemaTableTree . getSchemaTable ( ) ) ; } else { return true ; } } return false ; }
Checks if the stack has the same element more than once.

@param distinctQueryStack
@return true is there are duplicates else false