public static ClangSyntaxToken getNextBrace(ClangToken startToken, boolean forward) {

		int targetBalance = forward ? -1 : 1;
		Iterator<ClangToken> iter = startToken.iterator(forward);
		iter.next();	// skip the token itself;
		int nestLevel = 0;
		while (iter.hasNext()) {
			ClangToken token = iter.next();
			if (token instanceof ClangSyntaxToken) {
				String text = token.getText();
				if (text.equals("{")) {
					nestLevel += 1;
					if (nestLevel == targetBalance) {
						return (ClangSyntaxToken) token;
					}
				}
				else if (text.equals("}")) {
					nestLevel -= 1;
					if (nestLevel == targetBalance) {
						return (ClangSyntaxToken) token;
					}
				}
			}
		}
		return null;
	}
Starts at the given token and finds the next enclosing brace, depending on the given 
direction.  If going forward, the next unpaired closing brace will be returned; if going
backward, the next enclosing open brace will be found.   If no enclosing braces exist, 
then null is returned.

@param startToken the starting token
@param forward true for forward; false for backward
@return the next enclosing brace or null
Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/component/DecompilerUtils.java