public static ClangSyntaxToken getMatchingBrace(ClangSyntaxToken startToken) {

		boolean direction = "{".equals(startToken.getText());
		Iterator<ClangToken> iter = startToken.iterator(direction);
		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 == 0) {
						return (ClangSyntaxToken) token;
					}
				}
				else if (text.equals("}")) {
					nestLevel -= 1;
					if (nestLevel == 0) {
						return (ClangSyntaxToken) token;
					}
				}
			}
		}
		return null;
	}
Find the matching brace, '{' or '}', for the given brace token, taking into account brace nesting.
For an open brace, search forward to find the corresponding close brace.
For a close brace, search backward to find the corresponding open brace.
@param startToken is the given brace token
@return the match brace token or null if there is no match
Ghidra/Features/Decompiler/src/main/java/ghidra/app/decompiler/component/DecompilerUtils.java