algorithm for building all possible parentheses brackets