Program: 9933
Project: 9933
Buggy source:
/** 
 * PageNode won't be processed in following cases: Case 1: Node 's visibility is SYSTEM and the user is not superuser or he is superuser but acceptNonDisplayNode = false Case 2: Node 's visibility is not SYSTEM but the node is not display and the acceptNonDisplayedNode = false Case 3: Node has non null pageReference but the associated Page does not exist
 * @param startNode
 * @param userName
 * @param userService
 * @return
 * @throws Exception
 */
private static PageNode filterNodeNavigation(PageNode startNode,String userName,boolean acceptNonDisplayedNode,UserPortalConfigService userService,UserACL userACL) throws Exception {
  Visibility nodeVisibility=startNode.getVisibility();
  String pageReference=startNode.getPageReference();
  boolean doNothingCase_1=nodeVisibility == Visibility.SYSTEM && (!userACL.getSuperUser().equals(userName) || !acceptNonDisplayedNode);
  boolean doNothingCase_2=nodeVisibility != Visibility.SYSTEM && !startNode.isDisplay() && !acceptNonDisplayedNode;
  boolean doNothingCase_3=(pageReference != null) && (userService.getPage(pageReference,userName) == null);
  if (doNothingCase_1 || doNothingCase_2 || doNothingCase_3) {
    return null;
  }
  PageNode cloneStartNode=startNode.clone();
  ArrayList<PageNode> filteredChildren=new ArrayList<PageNode>();
  List<PageNode> children=startNode.getChildren();
  if (children != null) {
    for (    PageNode child : children) {
      PageNode filteredChildNode=filterNodeNavigation(child,userName,acceptNonDisplayedNode,userService,userACL);
      if (filteredChildNode != null) {
        filteredChildren.add(filteredChildNode);
      }
    }
  }
  if (filteredChildren.size() == 0 && cloneStartNode.getPageReference() == null) {
    return null;
  }
  cloneStartNode.setChildren(filteredChildren);
  return cloneStartNode;
}

Fixed version (ground truth):
/** 
 * PageNode won't be processed in following cases: Case 1: Node 's visibility is SYSTEM and the user is not superuser or he is superuser but acceptNonDisplayNode = false Case 2: Node 's visibility is not SYSTEM but the node is not display and the acceptNonDisplayedNode = false Case 3: Node has non null pageReference but the associated Page does not exist
 * @param startNode
 * @param userName
 * @param userService
 * @return
 * @throws Exception
 */
private static PageNode filterNodeNavigation(PageNode startNode,String userName,boolean acceptNonDisplayedNode,UserPortalConfigService userService,UserACL userACL) throws Exception {
  Visibility nodeVisibility=startNode.getVisibility();
  String pageReference=startNode.getPageReference();
  boolean doNothingCase_1=nodeVisibility == Visibility.SYSTEM && (!userACL.getSuperUser().equals(userName) || !acceptNonDisplayedNode);
  boolean doNothingCase_2=nodeVisibility != Visibility.SYSTEM && !startNode.isDisplay() && !acceptNonDisplayedNode;
  boolean doNothingCase_3=(pageReference != null) && (userService.getPage(pageReference,userName) == null);
  if (doNothingCase_1 || doNothingCase_2 || doNothingCase_3) {
    return null;
  }
  PageNode cloneStartNode=startNode.clone();
  ArrayList<PageNode> filteredChildren=new ArrayList<PageNode>();
  List<PageNode> children=startNode.getChildren();
  if (children != null) {
    for (    PageNode child : children) {
      PageNode filteredChildNode=filterNodeNavigation(child,userName,acceptNonDisplayedNode,userService,userACL);
      if (filteredChildNode != null) {
        filteredChildren.add(filteredChildNode);
      }
    }
  }
  if (!acceptNonDisplayedNode && filteredChildren.size() == 0 && cloneStartNode.getPageReference() == null) {
    return null;
  }
  cloneStartNode.setChildren(filteredChildren);
  return cloneStartNode;
}