{
NodeSetImpl filteredNodes = null;
Iterator checkAccessIter = nodes.iterator();
while (checkAccessIter.hasNext())
{
AbstractNode node = (AbstractNode)checkAccessIter.next();
try
{
// check visibility
checkVisibility(node, profiledFolders);
// add to filteredNodes nodes if copying
if (filteredNodes != null)
{
// permitted, add to filteredNodes nodes
filteredNodes.add(node);
}
}
catch (RuntimeException rte)
{
// create filteredNodes nodes if not already copying
if (filteredNodes == null)
{
// not permitted, copy previously permitted nodes
// to new filteredNodes node set with same comparator
filteredNodes = new NodeSetImpl(null, ((NodeSetImpl)nodes).getComparator());
Iterator copyIter = nodes.iterator();
while (copyIter.hasNext())
{
AbstractNode copyNode = (AbstractNode)copyIter.next();
if (copyNode != node)
{
filteredNodes.add(copyNode);
}
else