opendap/src/main/java/opendap/dap/DDS.java
private BaseType getDeepestMatchingVariable(DConstructor dcBT, Vector vNames)
    {

        // Get the first name from the Vector
        String vName = (String) vNames.get(0);

        // Get all of the child variables from the Dconstructor
        Enumeration bte = dcBT.getVariables();
        while (bte.hasMoreElements()) {
            // Get this variable
            BaseType bt = (BaseType) bte.nextElement();

            // Get and normalize it's name.
            String normName = normalize(bt.getClearName());

            // Compare the names
            if (normName.equals(vName)) {

                // They match!

                // Remove the name from the vector.
                vNames.remove(0);


                if (vNames.size() == 0) { // are there more names?
                    // Nope! We Found it!
                    return bt;
                }

                if (bt instanceof DConstructor) {
                    // If there are more names then this thing better be a container
                    // recursively search it for the remaining names...
                    BaseType nextBT = getDeepestMatchingVariable((DConstructor) bt, vNames);

                    if (nextBT != null)
                        return (nextBT);

                    return (bt);
                }

                return (bt);
            }
        }
        return (null);
    }
private BaseType getDeepestMatchingVariable(DConstructor dcBT, Vector vNames)
    {

        // Get the first name from the Vector
        String vName = (String) vNames.get(0);

        // Get all of the child variables from the Dconstructor
        Enumeration bte = dcBT.getVariables();
        while (bte.hasMoreElements()) {
            // Get this variable
            BaseType bt = (BaseType) bte.nextElement();

            // Get and normalize it's name.
            String normName = normalize(bt.getClearName());

            // Compare the names
            if (normName.equals(vName)) {

                // They match!

                // Remove the name from the vector.
                vNames.remove(0);


                if (vNames.size() == 0) { // are there more names?
                    // Nope! We Found it!
                    return bt;
                }

                if (bt instanceof DConstructor) {
                    // If there are more names then this thing better be a container
                    // recursively search it for the remaining names...
                    BaseType nextBT = getDeepestMatchingVariable((DConstructor) bt, vNames);

                    if (nextBT != null)
                        return (nextBT);

                    return (bt);
                }

                return (bt);
            }
        }
        return (null);
    }
This method executes a (recursive) search of the <code>DConstructor</code>
parameter <b>dcBT</b> for a <code>BaseType</code> variable whose name resolves to
the vector of names contained in the <code>Vector</code> parameter
<b>vNames</b>. A variable is considered a match if each of it's node
names in the hierarchy of containers in the
one passed as parameter <b>dcBT</b> matches (equals) the corresponding name
in the Vector <b>vNames</b>.

@param dcBT   The <code>DConstructor</code> to search
@param vNames The <code>Vector</code> of names to match to the nodes of <b>at</b>