'The constructor for the Prufer object.
Examples
>>> from sympy.combinatorics.prufer import Prufer
A Prufer object can be constructed from a list of edges:
>>> a = Prufer([[0, 1], [0, 2], [0, 3]])
>>> a.prufer_repr
[0, 0]
If the number of nodes is given, no checking of the nodes will
be performed; it will be assumed that nodes 0 through n - 1 are
present:
>>> Prufer([[0, 1], [0, 2], [0, 3]], 4)
Prufer([[0, 1], [0, 2], [0, 3]], 4)
A Prufer object can be constructed from a Prufer sequence:
>>> b = Prufer([1, 3])
>>> b.tree_repr
[[0, 1], [1, 3], [2, 3]]'

def __new__(cls, *args, **kw_args):

    ret_obj = Basic.__new__(cls, *args, **kw_args)
    args = [list(args[0])]
    if (args[0] and iterable(args[0][0])):
        if (not args[0][0]):
            raise ValueError('Prufer    expects    at    least    one    edge    in    the    tree.')
        if (len(args) > 1):
            nnodes = args[1]
        else:
            nodes = set(flatten(args[0]))
            nnodes = (max(nodes) + 1)
            if (nnodes != len(nodes)):
                missing = (set(range(nnodes)) - nodes)
                if (len(missing) == 1):
                    msg = ('Node    %s    is    missing.' % missing.pop())
                else:
                    msg = ('Nodes    %s    are    missing.' % list(sorted(missing)))
                raise ValueError(msg)
        ret_obj._tree_repr = [list(i) for i in args[0]]
        ret_obj._nodes = nnodes
    else:
        ret_obj._prufer_repr = args[0]
        ret_obj._nodes = (len(ret_obj._prufer_repr) + 2)
    return ret_obj
