{
if (nodes == null || nodes.length == 0)
{
return null;
}
AST root = nodes[0];
AST tail = null;
if (root != null)
{
root.setFirstChild(null);
}
for (int i = 1; i < nodes.length; i++)
{
if (nodes[i] != null)
{
if (root == null)
{
root = tail = nodes[i];
}
else if (tail == null)
{
root.setFirstChild(nodes[i]);
tail = root.getFirstChild();
}
else
{
tail.setNextSibling(nodes[i]);
tail = tail.getNextSibling();
}
while (tail.getNextSibling() != null)
{
tail = tail.getNextSibling();
}
}
}
return root;