def findkey(d, *keys):
if keys:<EOL><INDENT>keys = list(keys)<EOL>key = keys.pop(<NUM_LIT:0>)<EOL>return findkey(d[key], *keys)<EOL><DEDENT>else:<EOL><INDENT>return d<EOL><DEDENT>
Get a value from a dictionary based on a list of keys and/or list indexes.

Parameters
----------

d: dict
    A Python dictionary
keys: list
    A list of key names, or list indexes

Returns
-------

dict
    The composite dictionary object at the path specified by the keys

Example
-------

To return the value of the first class of the first layer in a Mapfile::

    s = '''
    MAP
        LAYER
            NAME "Layer1"
            TYPE POLYGON
            CLASS
                NAME "Class1"
                COLOR 0 0 255
            END
        END
    END
    '''

    d = mappyfile.loads(s)

    pth = ["layers", 0, "classes", 0]
    cls1 = mappyfile.findkey(d, *pth)
    assert cls1["name"] == "Class1"