<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def detect_circle(nodes):
 """ Wrapper for recursive _detect_circle function """

    # Verify nodes and traveled types
    if not isinstance(nodes, dict):
        raise TypeError('"nodes" must be a dictionary')

    dependencies = set(nodes.keys())
    traveled = []

    heads = _detect_circle(nodes, dependencies, traveled)

    return DependencyTree(heads)